使用cmake:dlopen集成FFMPEG失败:库"libavutil.so.56"未找到 [英] Integrating FFMPEG using cmake: dlopen failed: library "libavutil.so.56" not found

查看:1560
本文介绍了使用cmake:dlopen集成FFMPEG失败:库"libavutil.so.56"未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是此其他问题之后的后续主题我的.

在最终成功使用gradle和cmake成功构建了apk文件以将FFMPEG集成到Android项目中之后,我面临着一个新异常,该异常在调用System.loadLibrary时引发.

After finally managing to successfully building the apk file using gradle and cmake to integrate FFMPEG into an Android project I am facing a new exception which is thrown when calling System.loadLibrary.

java.lang.UnsatisfiedLinkError: dlopen failed: library "libavutil.so.56" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
        at java.lang.System.loadLibrary(System.java:1657)
        at com.hmomeni.canto.activities.EditActivity.<init>(EditActivity.kt:26)
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

这是导致错误的代码部分:

This is the part of code which is causing the error:

class EditActivity : AppCompatActivity(), View.OnClickListener {

    init {
        System.loadLibrary("Canto")
    }
...
}

我尝试将.so文件移到PROJECT/app/jniLibs内,然后将以下行添加到build.gradle文件中无济于事.

I tried moving the .so files inside the PROJECT/app/jniLibs and then adding the following line to build.gradle file to no avail.

sourceSets.main.jniLibs.srcDirs = ['./jniLibs/']

推荐答案

如果按以下方式配置 jniLibs.srcDirs :

sourceSets.main.jniLibs.srcDirs = ['./jniLibs/']

然后,您的路径app/jniLibs/ffmpeg/{ANDROID_ABI}/lib不正确,并且构建系统将找不到您的.so文件并将其打包.

Then your path app/jniLibs/ffmpeg/{ANDROID_ABI}/lib is not correct and your .so files won't be found and packaged by your build system.

尝试使您的 jniLibs 结构如下:

jniLibs
│   ├── x86
│   ├── x86_64
│   ├── arm64-v8a
│   ├── armeabi-v7a

不要在{ANDROID_ABI}/后面添加lib.

---编辑---

在使用System.loadLibrary手动加载库之后,我遇到了一个新错误,该错误表明libavutil具有文本重定位,并且对于API-23及更高版本,似乎不允许这样做.

And after manually loading the libraries using System.loadLibrary I encountered a new error which indicates that libavutil has text relocations and it seems that for API-23 and above it is not permitted.

也许您应该尝试使用选项--disable-asm-fPIC构建ffmpeg,以使二进制文件没有文本重定位.参见 https://stackoverflow.com/a/39965908/8034839 ,但NEON仍然存在一些问题.

Maybe you should try to build your ffmpeg with option --disable-asm and -fPIC to have a binary without text relocation. See here https://stackoverflow.com/a/39965908/8034839, but it looks there still some issue with NEON.

另一个讨论供您参考: https://stackoverflow.com/a/50207091/8034839

Another discussion for your information: https://stackoverflow.com/a/50207091/8034839

这篇关于使用cmake:dlopen集成FFMPEG失败:库"libavutil.so.56"未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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