Integrating FFMPEG using cmake: dlopen failed: library “libavutil.so.56” not found












1














This question is a subsequent thread following this other question of mine.



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")
}
...
}


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/']









share|improve this question
























  • what is your directory content inside /jniLibs/ ?
    – shizhen
    Nov 22 '18 at 2:13










  • @shizhen, sorry I'm replying this late. It's app/jniLibs/ffmpeg/{ANDROID_ABI}/lib.
    – Hamed Momeni
    Nov 25 '18 at 6:36










  • Your jniLibs.srcDirs should include the path till the level of directory ffmpeg and remove /lib.
    – shizhen
    Nov 25 '18 at 7:29


















1














This question is a subsequent thread following this other question of mine.



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")
}
...
}


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/']









share|improve this question
























  • what is your directory content inside /jniLibs/ ?
    – shizhen
    Nov 22 '18 at 2:13










  • @shizhen, sorry I'm replying this late. It's app/jniLibs/ffmpeg/{ANDROID_ABI}/lib.
    – Hamed Momeni
    Nov 25 '18 at 6:36










  • Your jniLibs.srcDirs should include the path till the level of directory ffmpeg and remove /lib.
    – shizhen
    Nov 25 '18 at 7:29
















1












1








1







This question is a subsequent thread following this other question of mine.



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")
}
...
}


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/']









share|improve this question















This question is a subsequent thread following this other question of mine.



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")
}
...
}


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/']






android ffmpeg cmake android-ndk linker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 7:39









shizhen

2,7373730




2,7373730










asked Nov 21 '18 at 19:39









Hamed MomeniHamed Momeni

4,00864787




4,00864787












  • what is your directory content inside /jniLibs/ ?
    – shizhen
    Nov 22 '18 at 2:13










  • @shizhen, sorry I'm replying this late. It's app/jniLibs/ffmpeg/{ANDROID_ABI}/lib.
    – Hamed Momeni
    Nov 25 '18 at 6:36










  • Your jniLibs.srcDirs should include the path till the level of directory ffmpeg and remove /lib.
    – shizhen
    Nov 25 '18 at 7:29




















  • what is your directory content inside /jniLibs/ ?
    – shizhen
    Nov 22 '18 at 2:13










  • @shizhen, sorry I'm replying this late. It's app/jniLibs/ffmpeg/{ANDROID_ABI}/lib.
    – Hamed Momeni
    Nov 25 '18 at 6:36










  • Your jniLibs.srcDirs should include the path till the level of directory ffmpeg and remove /lib.
    – shizhen
    Nov 25 '18 at 7:29


















what is your directory content inside /jniLibs/ ?
– shizhen
Nov 22 '18 at 2:13




what is your directory content inside /jniLibs/ ?
– shizhen
Nov 22 '18 at 2:13












@shizhen, sorry I'm replying this late. It's app/jniLibs/ffmpeg/{ANDROID_ABI}/lib.
– Hamed Momeni
Nov 25 '18 at 6:36




@shizhen, sorry I'm replying this late. It's app/jniLibs/ffmpeg/{ANDROID_ABI}/lib.
– Hamed Momeni
Nov 25 '18 at 6:36












Your jniLibs.srcDirs should include the path till the level of directory ffmpeg and remove /lib.
– shizhen
Nov 25 '18 at 7:29






Your jniLibs.srcDirs should include the path till the level of directory ffmpeg and remove /lib.
– shizhen
Nov 25 '18 at 7:29














1 Answer
1






active

oldest

votes


















2














If you configure your jniLibs.srcDirs as below:



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


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.



Try to make your jniLibs structure be as below:



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


Dont add lib behind {ANDROID_ABI}/.





---Edit---




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.




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.



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






share|improve this answer























  • I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
    – Hamed Momeni
    Nov 25 '18 at 8:06










  • Remove “.56” from your lib name
    – shizhen
    Nov 25 '18 at 8:54










  • Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
    – Hamed Momeni
    Nov 25 '18 at 9:01










  • Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
    – shizhen
    Nov 25 '18 at 9:03










  • Probably you need to explicitly load all the.so from init{} just like “Canto”
    – shizhen
    Nov 25 '18 at 9:07











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419416%2fintegrating-ffmpeg-using-cmake-dlopen-failed-library-libavutil-so-56-not-fou%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














If you configure your jniLibs.srcDirs as below:



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


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.



Try to make your jniLibs structure be as below:



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


Dont add lib behind {ANDROID_ABI}/.





---Edit---




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.




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.



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






share|improve this answer























  • I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
    – Hamed Momeni
    Nov 25 '18 at 8:06










  • Remove “.56” from your lib name
    – shizhen
    Nov 25 '18 at 8:54










  • Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
    – Hamed Momeni
    Nov 25 '18 at 9:01










  • Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
    – shizhen
    Nov 25 '18 at 9:03










  • Probably you need to explicitly load all the.so from init{} just like “Canto”
    – shizhen
    Nov 25 '18 at 9:07
















2














If you configure your jniLibs.srcDirs as below:



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


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.



Try to make your jniLibs structure be as below:



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


Dont add lib behind {ANDROID_ABI}/.





---Edit---




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.




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.



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






share|improve this answer























  • I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
    – Hamed Momeni
    Nov 25 '18 at 8:06










  • Remove “.56” from your lib name
    – shizhen
    Nov 25 '18 at 8:54










  • Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
    – Hamed Momeni
    Nov 25 '18 at 9:01










  • Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
    – shizhen
    Nov 25 '18 at 9:03










  • Probably you need to explicitly load all the.so from init{} just like “Canto”
    – shizhen
    Nov 25 '18 at 9:07














2












2








2






If you configure your jniLibs.srcDirs as below:



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


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.



Try to make your jniLibs structure be as below:



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


Dont add lib behind {ANDROID_ABI}/.





---Edit---




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.




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.



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






share|improve this answer














If you configure your jniLibs.srcDirs as below:



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


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.



Try to make your jniLibs structure be as below:



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


Dont add lib behind {ANDROID_ABI}/.





---Edit---




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.




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.



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







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 1:52

























answered Nov 25 '18 at 7:37









shizhenshizhen

2,7373730




2,7373730












  • I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
    – Hamed Momeni
    Nov 25 '18 at 8:06










  • Remove “.56” from your lib name
    – shizhen
    Nov 25 '18 at 8:54










  • Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
    – Hamed Momeni
    Nov 25 '18 at 9:01










  • Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
    – shizhen
    Nov 25 '18 at 9:03










  • Probably you need to explicitly load all the.so from init{} just like “Canto”
    – shizhen
    Nov 25 '18 at 9:07


















  • I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
    – Hamed Momeni
    Nov 25 '18 at 8:06










  • Remove “.56” from your lib name
    – shizhen
    Nov 25 '18 at 8:54










  • Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
    – Hamed Momeni
    Nov 25 '18 at 9:01










  • Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
    – shizhen
    Nov 25 '18 at 9:03










  • Probably you need to explicitly load all the.so from init{} just like “Canto”
    – shizhen
    Nov 25 '18 at 9:07
















I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
– Hamed Momeni
Nov 25 '18 at 8:06




I changed the directory structure to app/jniLibs/{ANDROID_ABI}/libavutil.so.56 but I'm still getting the same result. The library can not be found.
– Hamed Momeni
Nov 25 '18 at 8:06












Remove “.56” from your lib name
– shizhen
Nov 25 '18 at 8:54




Remove “.56” from your lib name
– shizhen
Nov 25 '18 at 8:54












Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
– Hamed Momeni
Nov 25 '18 at 9:01




Actually all versions of the file names are present in the directory. Check this image to see for yourself. imgur.com/a/j7s6Eka
– Hamed Momeni
Nov 25 '18 at 9:01












Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
– shizhen
Nov 25 '18 at 9:03




Have you analyzed your apk? Try to check whether your .so are packaged inside. I am using mobile, please forgive my brievity of reply.
– shizhen
Nov 25 '18 at 9:03












Probably you need to explicitly load all the.so from init{} just like “Canto”
– shizhen
Nov 25 '18 at 9:07




Probably you need to explicitly load all the.so from init{} just like “Canto”
– shizhen
Nov 25 '18 at 9:07


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419416%2fintegrating-ffmpeg-using-cmake-dlopen-failed-library-libavutil-so-56-not-fou%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python