加载共享库在Android的依赖 [英] Loading shared libraries with dependencies on Android

查看:211
本文介绍了加载共享库在Android的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我移植原生code的一大块​​几个相互依赖的库。加载code未能由于Android连接器不仅外观依赖于 /系统/ lib中/ ,而不是在应用程序的 /数据安装目录/数据/com.packagename.nnn/lib

作为第一个解决方法我加载的所有的.so的从Java与System.load()在正确的依赖顺序即可。该解决方案是不是对我满意,主要是因为该组库从生成更改构建由于插件架构。另外,用户界面​​应该不需要知道太多关于本机库。

我发现,Android不支持RPATH或设置LD_LIBRARY_PATH为应用。我发现的唯一的解决方法是完全合格的SONAMEs建库。

但一些依赖来到pre-建。


  1. 是否有可能编译完全合格的标签需要到我自己的图书馆,即使需要的。所以不具有完全合格的SONAME?


  2. 或者是有可能修改现有的.so和替换它的SONAME或完全合格的人需要不需要重新编译?



解决方案

Mozilla的Fennec的加载一堆共享对象从它们的/数据/数据​​/包/目录下创建一个自定义缓存目录,你可以看看他们的来源。

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?

解决方案

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.

这篇关于加载共享库在Android的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆