Android NDK crazy dependany : needed shared library has a path in it

0

I am building a ndk code base. I figured out what are the libraries needed and in my android.mk file I have mentioned the same by using LOCAL_LDLIBS += -l$(BASE_PATH)/libicuuc.so and few of them. It builds fine, but when I load it in the android appliation, it says "ucnv_open_52" symbol not found. I figured out that libicuuc.so is the culprit.Also I found in the system/lib in the emulator I do have a libicuuc.so file. But that one is something I don't want. I have build the libicuuc.so myself ( https://github.com/pelya/libiconv-libicu-android).

After bit of research I found a tool called arm-linux-androideabi-readelf.exe. When I run the it against my final so file it gives me the following.

 0x00000001 (NEEDED)                     Shared library: [libstlport_shared.so]
 0x00000001 (NEEDED)                     Shared library: [libBase.so]
 0x00000001 (NEEDED)                     Shared library: [/usr/local/src/android-ndk-r9c/Android-porting-baseline/jni/libicuuc.so]
 0x00000001 (NEEDED)                     Shared library: [libmnk.so]
 0x00000001 (NEEDED)                     Shared library: [libxyz.so]
 0x00000001 (NEEDED)                     Shared library: [libabc.so]
 0x00000001 (NEEDED)                     Shared library: [libdef.so]
 0x00000001 (NEEDED)                     Shared library: [libghi.so]
 0x00000001 (NEEDED)                     Shared library: [libjkl.so]
 0x00000001 (NEEDED)                     Shared library: [libopq.so]
 0x00000001 (NEEDED)                     Shared library: [libzer.so]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x0000000e (SONAME)                     Library soname: [libFinal.so]

I have changed the names , since I belive they are irrelevant. But do note the third line . I don't understand why libiccuc.so has a path. May be this is the reason why it fails.

Please help

android
android-ndk

2 Answers

0

Well, I solved my own problem.

libicuuc.so is present in my device / AVD, many devices do come with libicuuc.so, but the shipped version of the this so file doesn't contain the symbol which my code is dependent upon. So essentially trying to load the libicuuc.so by using system.loadlibrary() somehow loads the system library, which I don't want.

So I build the libicuuc.so with a different module name lets say icuucx ,thus it gives me libicuucx.so , which I loaded by using system.loadlibrary() and it worked.

answered on Stack Overflow Apr 21, 2014 by Abhiram mishra
0

I had similar problem: my JNI so depends on 2 prebuilt shared libraries, one of them included by name only, another - with local build path. The difference was in missing SONAME attribute for 2nd one. Problem has been fixed after I rebuilt 2nd library with 'SONAME' generation. In your case, when linking libicuuc.so please add "-Wl,-soname,libicuuc.so" to command line.

answered on Stack Overflow May 4, 2017 by Timofey Mokhnatkin

User contributions licensed under CC BY-SA 3.0