Loading shared libraries with dependencies on Android

自闭症网瘾萝莉.ら 提交于 2019-12-22 08:15:39

问题


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 for 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.

  1. Is it possible compile fully qualified NEEDED tag into my own library even when the needed .so does not have fully qualified SONAME?

  2. Or is it possible to modify existing .so and replace its SONAME or NEEDED with fully qualified one without recompiling?


回答1:


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.



来源:https://stackoverflow.com/questions/7247901/loading-shared-libraries-with-dependencies-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!