您的位置:首页 > 其它

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

2017-06-15 16:18 633 查看
最近本人研究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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ffmpeg x86 交叉编译