Android:加载预建库 - 循环依赖关系丢失

时间:2015-06-10 05:44:06

标签: android android-ndk android.mk

我正在尝试将模块导入我的项目。

模块中的Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CEAR_VARS)
LOCAL_MODULE := fromhere1
LOCAL_MODULE_FILENAME := fromhere1
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfromhere.so
include $(PREBUILT_SHARED_LIBRARY)

libfromhere.so由ndk-build

构建

我的项目中的Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)


LOCAL_MODULE    := native
LOCAL_MODULE_FILENAME  := libnative
LOCAL_SRC_FILES := native.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
LOCAL_SHARED_LIBRARIES := fromhere1
include $(BUILD_SHARED_LIBRARY)


$(call import-module,module)

当我运行ndk-build时,我收到错误

[arm64-v8a] Compile        : native <= native.c
make: Circular /home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so <- /home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so dependency dropped.
[arm64-v8a] SharedLibrary  : libnative.so
aarch64-linux-android-g++: error: /home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so: No such file or directory
make: *** [/home/raghuram/DS-5-Workspace/helloworld/obj/local/arm64-v8a/libnative.so] Error 1.

我不明白为什么会产生这种循环依赖。 我遵循了正确的语法。

2 个答案:

答案 0 :(得分:1)

包含$(PREBUILT_SHARED_LIBRARY)后你必须清除变量可能是你再次预建另一个库...这个东西解决了我的问题:)

LOCAL_PATH := $(call my-dir)

include $(CEAR_VARS)
LOCAL_MODULE := fromhere1
LOCAL_MODULE_FILENAME := fromhere1
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfromhere.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CEAR_VARS)

LOCAL_MODULE := fromhere2
LOCAL_MODULE_FILENAME := fromhere2
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfromhere2.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CEAR_VARS)

答案 1 :(得分:0)

我的错误是LOCAL_MODULE_FILENAME的值。它必须是libfromhere1而不是fromhere1。 ndk只是将.so后缀添加到给定名称但它不会放置lib前缀。 总是最好自己给出名字,而不是让ndk为你命名。

但是我不明白为什么会因此而产生循环依赖。