与 Android NDK 中的版本化共享库链接 [英] Linking with versioned shared library in Android NDK
问题描述
我正在尝试通过 loadLibrary
调用在我的 Android 应用程序中加载两个共享库:
I am trying to load two shared libraries in my Android application through the loadLibrary
call:
System.loadLibrary("mywrapper");
System.loadLibrary("crypto");
我一直在运行,捕获 `UnsatisfiedLinkError.这是错误的更详细版本.
I keep running catching the `UnsatisfiedLinkError. Here is a more detailed version of the error.
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1969]:
130 could not load needed library 'libcrypto.so.1.0.0' for
'libmywrapper.so' (load_library[1111]: Library 'libcrypto.so.1.0.0' not found)
有什么想法吗?
花了一些时间后,我发现 Android 不支持版本库.有没有人遇到过同样的问题?
After spending some time I found out that Android doesn't support versioned libraries. Has any one faced the same issue?
推荐答案
我在为Android构建libwebsockets时遇到了同样的问题,需要与OpenSSL链接.我以 libssl.so 为例.您应该对相关的 .so 文件执行相同的操作.
I had the same problem on building libwebsockets for Android, which needs to link with OpenSSL. I use libssl.so as example. You should do the same for related .so files.
Before:
huiying@huiying-PORTEGE-R835:~$ objdump -p libssl.so | grep so
libssl.so: file format elf32-little
NEEDED libcrypto.so.1.0.0
NEEDED libdl.so
NEEDED libc.so
SONAME libssl.so.1.0.0
After
huiying@huiying-PORTEGE-R835:~$ rpl -R -e .so.1.0.0 "_1_0_0.so" libssl.so
Replacing ".so.1.0.0" with "_1_0_0.so" (case sensitive) (partial words matched)
.
A Total of 2 matches replaced in 1 file searched.
huiying@huiying-PORTEGE-R835:~$ objdump -p libssl.so | grep so
libssl.so: file format elf32-little
NEEDED libcrypto_1_0_0.so
NEEDED libdl.so
NEEDED libc.so
SONAME libssl_1_0_0.so
And don't forget to change file name "libssl.so" to "libssl_1_0_0.so".
破解有效.我已经运行 Android 应用程序来证明这一点.在 http://computervisionandjava.blogspot.com 查看我的咆哮/2015/05/trouble-with-versioned-shared-libraries.html.
The hack works. I have running Android app to prove it. See my rant at http://computervisionandjava.blogspot.com/2015/05/trouble-with-versioned-shared-libraries.html.
这篇关于与 Android NDK 中的版本化共享库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!