Unable to dlopen(libsomething.so) Cannot load library: link_image[1995]: failed to link libsomething.so

后端 未结 4 1131
日久生厌
日久生厌 2020-12-16 14:28

I am writing an android project which has Native layer helping the java layer, and am stuck at a place where when i try to do a System.loadLibrary, it is throwing error that

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 15:02

    Sometimes (most of the time!) you library requires other libraries as mentioned by @musefan. and you can list them doing readelf -d libs/armeabi/libmy.so. However there is a catch here: since Android has no any mechanism to control library version (like in normal linux you have liblzma.so.1, liblzma.so.2, etc) the library you need is there (liblzma.so) BUT has no some symbols imported by your library. Here is the live example: you use android::ZipFileRO::getEntryInfo function located in libutils.so. All version of the library has this function however the PROTOTYPE of the function has been changed at the end of 2010 so you app built for 4.0.4 NDK will not run on FroYo devices or GB devices with the same symptomatic: dlopen cannot load library. Here is the recipe how to detect such cases: you need the contents os /system/lib folder on your PC. It may be folder dumped from your device if you are 3rd party App developed or built if you are platform developer. then issue the command arm-linux-gnueabi-ld -rpath-link /path/to/system/lib ./lib_mylib.so and you will see something lie this in case of error
    lib_mylib.so: undefined reference toandroid::ZipFileRO::getEntryInfo(void*, int*, long*, long*, long*, long*, long*) const'`

提交回复
热议问题