How do I load a native library (.so) from another native library (.so)?

夙愿已清 提交于 2019-12-11 15:49:06

问题


So, my code right now is like it loads library (say liba.so) from Java-layer and internally liba.so loads libb.so. So, if I have to pack all the libraries inside an APK and install it on a device with no root access then what is the procedure to structure my project in which one load call from Java-layer will load both the libraries, first liba.so (direct call) and then libb.so (second call, nested call, call from liba.so)?


回答1:


If both liba.so and libb.so are packed into your APK, then the installer will unpack both to the nativeLibraryDir.

From Java, loadLibrary() will look in this directory automatically. But dlopen() is not aware of this path. You must provide to dlopen() the full path to the installed libb.so.

Alternatively, you can load libb from Java, then it will be in memory and liba will find it's exported symbols without dlopen().

If you need to understand better the process of packing the libraries into APK, consult this wonderful answer.



来源:https://stackoverflow.com/questions/48579189/how-do-i-load-a-native-library-so-from-another-native-library-so

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