Android NDK:dlopen失败 [英] Android NDK: dlopen failed
问题描述
我有一个奇怪的错误,上面写着:
I have a weird error where it says:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot find "./obj/local/armeabi-v7a/libsharedlibrary.so" from verneed[1] in DT_NEEDED list for "/data/data/com.my.app/cache/libnative.so"
我已经尝试了很多,但是我听不懂.我希望那里的任何人都能帮助我!预先感谢!
I have tried a lot, but I don't understand it. I hope anyone out there can help me! Thanks in advance!
它不是这个问题的重复项,因为它不是相同的错误.这个问题的答案对我没有帮助...
It is not a diplicate of this question, as it is not the same error. The answer on that question does not help me...
推荐答案
libsharedlibrary.so缺少其SONAME条目.您目前可能会看到类似以下的内容:
libsharedlibrary.so is missing its SONAME entry. You probably currently see something like the following:
$ readelf -dW libnative.so | grep NEEDED | grep libsharedlibrary
0x0000000000000001 (NEEDED) Shared library: [./obj/local/armeabi-v7a/libsharedlibrary.so]
请注意,如果您的系统上没有readelf,则它在NDK中以$ NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf的形式提供(根据您的操作系统调整路径).请注意,这里的架构实际上并不重要. readelf是一个多体系结构工具.任何工具链的readelf都可以正常工作.
Note that if you don't have readelf on your system it is provided in the NDK as $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf (adjust the path as necessary for your OS). Note that the architecture here doesn't actually matter. readelf is a multi-arch tool. Any toolchain's readelf will work fine.
如果libsharedlibrary.so是用SONAME构建的,您应该看到的是:
What you should see if libsharedlibrary.so was built with SONAME is:
$ readelf -dW libnative.so | grep NEEDED | grep libsharedlibrary
0x0000000000000001 (NEEDED) Shared library: [libsharedlibrary.so]
您应该在libsharedlibrary.so上看到以下内容:
You should see the following on libsharedlibrary.so:
$ readelf -dW libsharedlibrary.so | grep SONAME
0x000000000000000e (SONAME) Library soname: [libsharedlibrary.so]
问题是libsharedlibrary.so不是用-Wl,-soname,libsharedlibrary.so
ldflag构建的. ndk-build和CMake将为您做到这一点,但是,如果您使用的是独立工具链或自定义构建系统,则需要自己提供.
The problem is that libsharedlibrary.so was not built with the -Wl,-soname,libsharedlibrary.so
ldflag. ndk-build and CMake will do that for you, but if you're using a standalone toolchain or a custom build system then you need to provide it yourself.
这篇关于Android NDK:dlopen失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!