我无法找到Android NDK module importation feature的实际示例。以下Android.mk文件看起来是正确的,内部模块构建并执行没有错误。但是,构建外部模块失败,并显示以下错误消息:
Android NDK:jni / inner / Android.mk:inner:LOCAL_MODULE_FILENAME不应包含文件扩展名
Android NDK:jni / inner / Android.mk:inner:LOCAL_MODULE_FILENAME不得包含文件扩展名
/home/caleb/dev/android-ndk-r8e/build/core/build-shared-library.mk:30: * Android NDK:正在中止。停止。
内置的Android.mk文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := inner
LOCAL_MODULE_FILENAME := libinner
LOCAL_SRC_FILES := inner-module.c
include $(BUILD_SHARED_LIBRARY)
外部,包含Android.mk文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := outer
$(call import-module,inner)
LOCAL_SHARED_LIBRARIES += inner
include $(BUILD_SHARED_LIBRARY)
答案 0 :(得分:4)
尝试将调用放在外部文件末尾的import-module中。在引用“内部”之前放置它并不是必须的,NDK文档实际上建议您将它放在最后。
答案 1 :(得分:2)
你正在做的事情有一些问题所以这就是事情的样子。
内置的Android.mk文件:
# save away the previous local path
INNER_SAVED_LOCAL_PATH := $(LOCAL_PATH)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := inner
LOCAL_MODULE_FILENAME := libinner
LOCAL_SRC_FILES := inner-module.c
include $(BUILD_SHARED_LIBRARY)
# at this point LOCAL_MODULE_FILENAME will have been auto
# set to libinner.so or similar by the call to BUILD_SHARED_LIBRARY
# restore previous local path
LOCAL_PATH := $(INNER_SAVED_LOCAL_PATH)
外部,包含Android.mk文件:
LOCAL_PATH := $(call my-dir)
$(call import-module,inner)
# at this point
# a) we've still got the correct LOCAL_PATH as we didn't trash it in
# the included Android.mk file
# b) LOCAL_MODULE_FILENAME is still set to libinner.so which if not
# unset will cause BUILD_SHARED_LIBRARY to complain
include $(CLEAR_VARS)
# we've now got a clean slate
LOCAL_MODULE := outer
# the build system has 'remembered' the inner module
LOCAL_SHARED_LIBRARIES += inner
include $(BUILD_SHARED_LIBRARY)
我不确定这是 方式,但它适用于我:)