简体   繁体   中英

could not load library “libdl.so.2”

I have been trying to use linux compiled prebuilt shared library with my android jni application, but when i try to run the application it gives following error:

04-16 19:09:13.633: E/dalvikvm(11810): dlopen("/data/app-lib/com.lXXXX.XXXX.connect-2/libXXX_embedded_shared.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1636): could not load library "libdl.so.2" needed by "libXXX_embedded_shared.so"; caused by load_library(linker.cpp:746): library "libdl.so.2" not found

i could not find libdl.so.2 in android/system/lib but there is a library libdl.so which i tried to load but it still did not resolve the dependency.

Can you please point me what i am missing here?

You cannot do this.

Android and a normal linux have vastly different userspaces, in particular they use entirely different C libraries and associated incompatible dynamic linkers.

The very desire for a versioned library name (the .so.2 - something Android doesn't currently do) is indicative that this library was not build for Android.

You need to rebuild all your libraries using the android ndk either by creating and Android.mk and similar files to drive the normal ndk build system, or by using the ndk utility for generating a "stand alone toolchain" and pointing your project's build system at the resulting android-targeted gcc, ld, etc.

Some people have managed to use normal linux userspace components on rooted devices by putting a whole minimal install of debian-arm or similar in a chroot, but that requires root to set up and would not be linkable from an application process by jni anyway. Your application process is already deeply tied to Android's C library so you can't really substitute another.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM