开发者

Loading shared libraries with dependencies on Android

开发者 https://www.devze.com 2023-04-01 09:01 出处:网络
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 di

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.

  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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号