Android : Loading pre-built library - Circular dependency dropped

624 views Asked by At

I am trying to import a module into my project.

Android.mk in module:

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 is built by ndk-build

Android.mk in my project:

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)

When I run ndk-build, I get error

[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.

I don't understand why that circular dependency is arising. I followed proper syntax.

2

There are 2 answers

0
Raghuram Vadapalli On BEST ANSWER

My mistake is the value of LOCAL_MODULE_FILENAME. It must be libfromhere1 instead of fromhere1. ndk just puts .so suffix to the given name but it won't put lib prefix. Always it is better to give name by yourself than letting ndk name it for you.

But I didn't understand why circular dependency arose because of that.

0
AnkitSahu On

After include $(PREBUILT_SHARED_LIBRARY) you have to clear the variable may be you are again prebuilding another library... this stuff solved my issue :)

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)