Android NDK:dlopen 失败 [英] Android NDK: dlopen failed

查看:70
本文介绍了Android NDK:dlopen 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的错误,它说:

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆