LD_LIBRARY_PATH ignored on Android sometimes

后端 未结 4 2040
有刺的猬
有刺的猬 2021-02-06 15:59

i have an android app which spawns many native executables dinamically linked with libraries i distribute with the package. To launch those binaries, i use the LD_LIBRARY_PATH e

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 16:34

    That's correct, you cannot rely on LD_LIBRARY_PATH on Android. You can use System.load() with any library, but this does not really help when you spawn child processes. You can use dlopen in your code, but usually it means that many lines of code must be rewritten.

    A funny trick is to convert your executables into shared libraries, and load them from wrapper executables which would dlopen the libraries in dependency order.

    It is highly recommended though to convert as many spawns as possible into in-process calls.

提交回复
热议问题