java.lang.UnsatifiedLinkError: dlopen failed:library "libXXXXX.so.0"not found

Asked 1 years ago, Updated 1 years ago, 64 views

Attempted to create libXXXXX.so by cross-compiling the third-party code for Android.The app is Android Studio and the build was successful, but when running the app, the following error occurs:

logcat error log

java.lang.UnsatisfiedLinkError: dlopen failed:library"libXXXXX.so.0"not found

so.0 on libXXXXX.so is somehow the cause, but I don't know what to do with Android Studio.

The readelf command is as follows:

$readelf-d libXXXXX.so | grep SONAME
0x00000000000000000e (SONAME) Library soname: [libXXXXX.so.0]

CMakeLists.txt is as follows

add_libXXXX SHARED IMPORTED)

set_target_properties(libXXXXX)
    PROPERTIES
    IMPORTED_LOCATION${LIB_ROOT}/cpp/libs/${ANDROID_ABI}/libXXXXX.so)

add_library (hello-jni SHARED src/main/cpp/hello-jni.cpp)

target_link_libraries (hello-jnilibXXXX${log-lib})

The Java code is as follows:

static{
    System.loadLibrary ("hello-jni");
}

·Even if I put libXXXXX.so.0 in the same location as the so file, the error remained.
·I also tried libXXXXXX.a (STATIC LIBRARY) and it was successfully executed.

I thought I might add SONAME-related options to CMakeLists.txt, but I didn't really understand.I look forward to working with you on the solution.

The situation has changed.

Failed to loadLibrary

static{
    System.loadLibrary("XXXX";
    System.loadLibrary ("hello-jni");
}

New logcat error log

java.lang.UnsatisfiedLinkError: dlopen failed:cannot locate symbol**"acos"**referenced by"...libXXXXX.so"...

Regarding the error without acos, is there no acos on Android?Is it difficult to solve this problem?Thank you for your cooperation.

I tried to change the following, but the situation did not change (remain the same error)

CMakeLists.txt

target_link_libraries (hello-jnilibXXXXm${log-lib})

Java Code

static{
    System.loadLibrary("m");
    System.loadLibrary("XXXX";
    System.loadLibrary ("hello-jni");
}

Thank you for your continued support.

android android-studio

2022-09-30 13:46

1 Answers

I got there looking into a similar problem myself.
I found this document about API24 and later restrictions.
https://android.googlesource.com/platform/bionic/+/372f19e/android-changes-for-ndk-developers.md#private-api-enforced-for-api-level-24

The native library uses only public APIs and should not be linked to non-NDK platform libraries.API24
From the , this rule is applied and applications are no longer able to read non-NDK platform libraries.Because this rule is enforced by dynamic linkers, non-public libraries are not accessible regardless of how the code is read.System.loadLibrary, DT_NEEDED
Entries and direct calls to dlopen(3) all behave exactly the same way.


2022-09-30 13:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.