Reputation: 30492
I have 2 shared libraries: lib1.so and lib2.so.
lib1.so contains some functions which are defined in lib2.so. From a C program I load lib1.so using following call:
dlopen( "lib1.so", RTLD_NOW );
Both libraries are presented in the current directory. My program works under a desktop Linux (Ubuntu, Debian), but not under Android. Under Android dlopen returns an Error and exits. I tried to set:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
but it doesn't help.
I am totally confused, why this code doesn't work under Android. I cannot find any good documentation on Android's dynamic linker. So, I have no explanation why it doesn't work.
DETAILS:
Upvotes: 2
Views: 2462
Reputation: 30492
Ok. I just found a solution. Adding -lgcc to linker options for lib1.so has solved it. It looks like compiler has auto-generated some calls to special built-in functions from libgcc. It also requires -lc because compiler also auto-generates special calls to memcpy.
Upvotes: 2
Reputation: 86343
if dlopen
does not work for some reason, have you tried to call dlerror
to find out what the real problem is?
Upvotes: 1
Reputation: 517
I not very sure about your project. But I think, it better to load you library from a Service using System.loadLibrary).
System.loadLibrary(lib.so); In your case first load lib2.so and then only load lib1.so
Upvotes: 0