Loading shared libraries with dependencies on Android
I'm porting a big chunk of native code with several interdependent libraries. Loading the code fails since Android linker only looks dependencies in /system/lib/
and not in the application install directory at /data/data/com.packagename.nnn/lib
.
As a first workaround I loaded all .so's from Java with System.load() in correct dependency order. This solution isn't satisfactory fo开发者_开发问答r me mostly because the set of libraries changes from build to build due to plugin architecture. Also the UI shouldn't need to know that much about native libs.
I've found that Android does not support RPATH or setting LD_LIBRARY_PATH for an app. The only workaround I found is building the libraries with fully qualified SONAMEs.
However some of the dependencies come pre-built.
Is it possible compile fully qualified NEEDED tag into my own library even when the needed .so does not have fully qualified SONAME?
Or is it possible to modify existing .so and replace its SONAME or NEEDED with fully qualified one without recompiling?
Mozilla Fennec loads a bunch of shared objects from a custom cache directory under their /data/data/package/ directory, you might take a look at their source.
精彩评论