包括来自预建立的库Android.mk的头文件

时间:2017-10-02 18:39:24

标签: c++ maven cmake android-ndk java-native-interface

我已经使用

将预建库包含到我的库创建中
include $(PREBUILT_SHARED_LIBRARY)
使用

包含或不包含已验证的天气库
$(modules-get-list)

当我尝试在预构建的库中包含头文件时,我遇到错误标题未找到。以下是我确切的Android.mk文件

LOCAL_PATH := $(call my-dir)

# import prebuilt-library
include $(CLEAR_VARS)
LOCAL_MODULE    := prebuilt-library
LOCAL_SRC_FILES := ../../../target/dependency/libs/$(TARGET_ARCH_ABI)/libprebuilt.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

# building provider interface library for communication
include $(CLEAR_VARS)
LOCAL_MODULE := library-interface
LOCAL_SRC_FILES := LibraryComminicator.cpp
LOCAL_SHARED_LIBRARIES := prebuilt-library

include $(BUILD_SHARED_LIBRARY)

$(warning Existing modules: "$(modules-get-list)")

# Include the Android Maven plugin generated makefile
# Important: Must be the last import in order for Android Maven Plugins paths to work
include $(ANDROID_MAVEN_PLUGIN_MAKEFILE)

1 个答案:

答案 0 :(得分:1)

尝试下面的 Android.mk

{
  const checked = new Set();
  const dig = (value, o=window, path='') => {
    function check(v, name) {
      if ((typeof v == 'string' || typeof v == 'number')
      && String(v).toLowerCase().includes(value)) {
        console.log('%s in %s %o', v, path + name, o);
      } else if (v && typeof v == 'object' && v != window && !v.nodeName) {
        dig(value, v, path + name + '.');
      }
    }
    if (o && o.forEach) {
      for (let len = o.length, i; i < len; i++)
        check(o[i], `[${i}]`);
    } else if (typeof o == 'object') {
      for (const k of Object.getOwnPropertyNames(o)) {
        if (k.startsWith('webkit'))
          continue;
        try {
          const v = o[k];
          if (checked.has(v))
            continue;
          checked.add(v);
          check(v, k);
        }
        catch(e) {}
      }
    } else
      check(v);
  };

  console.group();
  dig('JohnSmith');
  console.groupEnd();
}

基本规则是:xxx_INCLUDE_FILES应相对于'当前目录',而LOCAL_SRC_FILES相对于$(LOCAL_PATH),而不是'当前目录'。使用NDK时,通常“当前目录”为LOCAL_PATH := $(call my-dir) EXT_LIB_ROOT := $(LOCAL_PATH)/../../../target/dependency # or whatever # building provider interface library for communication include $(CLEAR_VARS) LOCAL_MODULE := library-interface LOCAL_SRC_FILES := LibraryComminicator.cpp LOCAL_SHARED_LIBRARIES := prebuilt-library include $(BUILD_SHARED_LIBRARY) # import prebuilt-library LOCAL_PATH := $(EXT_LIB_ROOT) include $(CLEAR_VARS) LOCAL_MODULE := prebuilt-library LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libprebuilt.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_SHARED_LIBRARY) $(warning Existing modules: "$(modules-get-list)") ,但这可能会发生变化,尤其是在 Android.mk 文件被链接的情况下,即一个包含另一个。

你真的不需要LOCAL_PATH用于PREBUILT_SHARED_LIBRARY模块,但我更喜欢让LOCAL_SRC_FILES保持尽可能短。