ffmpeg安卓x86平台编译错误(libavcodec.so: has text relocations)

来源:互联网 发布:mac os x系统使用教程 编辑:程序博客网 时间:2024/05/21 17:23
最近本人研究ffmpeg编译,在使用ndk交叉编译x86平台的.so库文件后,加载使用时,出现错误 java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/xxx.xxx.xxx-1/lib/x86/libavcodec.so: has text relocations

原因是android 6.0之后,系统做了限制。

“On previous versions of Android, if your app requested the system to load a shared library with text relocations, the system displayed a warning but still allowed the library to be loaded. Beginning in this release, the system rejects this library if your app’s target SDK version is 23 or higher. To help you detect if a library failed to load, your app should log the dlopen(3) failure, and include the problem description text that the dlerror(3) call returns. To learn more about handling text relocations, see this guide”

针对这个说法,网上很多朋友用降低targetSDK版本的方式来解决,但如果不降低如何解决呢?

从ffmpeg官网有问题单描述,如下:

这里写图片描述
官方描述中,x86平台会出现此问题,而armv7-a 、x86_64都没有这样的问题,所以只需要针对x86平台解决即可。

OK,可以通过编译时添加 –disable-asm参数解决,设置参数关闭汇编后,编译后.so文件就不存在text relocations了。

可以通过以下方式检查,so文件中是否存在text relocations。
这里写图片描述

如果存在text relocations,会出现类似以下

0x00000016 (TEXTREL)            0x0

如果grep不到TEXTREL,如下图:
这里写图片描述

参考:
https://trac.ffmpeg.org/ticket/4928
https://stackoverflow.com/questions/32845956/android-m-crash-java-lang-unsatisfiedlinkerror-dlopen-failed
https://stackoverflow.com/questions/32346402/libavcodec-so-has-text-relocations

阅读全文
0 0
原创粉丝点击