与Android NDK中的版本共享库链接 [英] Linking with versioned shared library in Android NDK

查看:164
本文介绍了与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屋!

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