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

后端 未结 4 1124
日久生厌
日久生厌 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条回答
  • 2020-12-16 14:59

    I've trap in the same question. finally I got answer from this article: http://mpigulski.blogspot.com/2010/09/debugging-dlopen-unsatisfiedlinkerror.html

    use

    arm-linux-androideabi-readelf.exe  -d libs/armeabi/libmy.so
    

    Then Found a NEEDED Shared library in wrong name.

    0 讨论(0)
  • 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'`

    0 讨论(0)
  • 2020-12-16 15:05

    First find the location of the .so file. and then can try:

    Following example assumes the location of shared library as: /data/data/my.package/lib/libmysharedlibrary.so

    try {
        //System.loadLibrary("mysharedlibrary");
        System.load("/data/data/my.package/lib/libmysharedlibrary.so");
    } catch (UnsatisfiedLinkError use) {
        Log.e("JNI", "WARNING: Could not load libmysharedlibrary.so");
    }
    
    0 讨论(0)
  • 2020-12-16 15:14

    You can also find this error while using calling System.load(String pathName) method and just passing libraryName instead of complete path to library.

    Resolution : use System.loadLibrary(String libName) method and now pass the libraryName.

    0 讨论(0)
提交回复
热议问题