Reputation: 197
I am trying to use two prebuilt native libraries (.so) in my Android application. For this i have created a JNI project where i have done the following,
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmodule1
LOCAL_SRC_FILES := prebuilts/$(TARGET_ARCH_ABI)/libmodule1.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libmodule2
LOCAL_SRC_FILES := prebuilts/$(TARGET_ARCH_ABI)/libmodule2.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := com_example_androidwrapper_NativeLibrary
LOCAL_SRC_FILES := com_example_androidwrapper_NativeLibrary.c
LOCAL_SHARED_LIBRARIES := libmodule1 libmodule2
include $(BUILD_SHARED_LIBRARY)
When i run this app I am getting the following error.
java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++.so" not found
If i dont load the module1, module2 libraries app will work fine (i commented out the calls to the methods exposed by these two modules and rewrote the Android.mk file to just to build a shared library and not to use any prebuilt ones) This is working fine.
Any help is appreciated. Thanks.
I had successfully used the prebuilt .so files from a native application which i ran in the same target device. When i changed the application.mk "APP_ABI := all" It gave me the following error.
[x86_64] Prebuilt : module1.so <= jni/
[x86_64] Install : module1.so => libs/x86_64/module1.so
C:/Users/user/AppData/Local/Android/android-ndk-r12b/build//../toolchains/x86_64-4.9/prebuilt/windows/bin/x86_64-linux-android-strip: Un
able to recognise the format of the input file `./libs/x86_64/module1.so'
make: *** [libs/x86_64/module1.so] Error 1
make: *** Deleting file `libs/x86_64/module1.so'
I think the prebuilt .so files are supposed to run in the arm64-v8a itself.
Upvotes: 1
Views: 8190
Reputation: 10509
What is libmodule1.so? It sounds like it's a library that you pulled off an android device and are trying to use. That's pretty much only going to work for the exact device you pulled it from.
As for the second part, it sounds like the libraries in your x86_64 directory aren't actually x86_64 libraries. Try $NDK/toolchains/x86_64-4.9/prebuilt/$YOUR_OS/bin/x86_64-linux-android-readelf -h module1.so
. It will print the ELF header for the library. One of the lines should be:
Machine: Advanced Micro Devices X86-64
If the value of machine is anything else, it's not an x86_64 library.
Upvotes: 1