简体   繁体   English

在 OpenCV android 应用程序中启用“libc++_shared.so”

[英]enabling "libc++_shared.so" to be enabled in the OpenCV android application

I wand to implement a project with OpenCV .我想用 OpenCV 实现一个项目。 I have imported the the OpenCV SDK in the project and i am getting the error in as follows:-我在项目中导入了 OpenCV SDK,出现如下错误:-

java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found

i have read your solution in stackoverflow.我已在 stackoverflow 中阅读了您的解决方案。 The link is as below:-链接如下:-

Android Studio CMake - shared library missing libc++_shared.so? Android Studio CMake - 共享库缺少 libc++_shared.so? Can CMake bundle this? CMake 可以捆绑这个吗?

and i have tried to implement a solution from github:-我试图从 github 实现一个解决方案:-

https://github.com/jomof/ndk-stl/blob/master/ndk-stl-config.cmake https://github.com/jomof/ndk-stl/blob/master/ndk-stl-config.cmake

I could not find any solution.我找不到任何解决方案。

I just want "libc++_shared.so" packaged into the apk and the SDK runs properly in my project.我只想将“libc++_shared.so”打包到 apk 中,并且 SDK 在我的项目中正常运行。 i have no knowledge about the build tool cmake or ndk-build.我对构建工具 cmake 或 ndk-build 一无所知。

Please give a simple solution so that i can enable "libc++_shared.so" in the application so that the OpenCV project run properly.请给出一个简单的解决方案,以便我可以在应用程序中启用“libc++_shared.so”,以便 OpenCV 项目正常运行。

My Error Log looks as below.我的错误日志如下所示。

在此处输入图片说明

My Project structure looks as:-我的项目结构如下:-

在此处输入图片说明

Earlier i have added CMakeLists.txt as mentioned in the OpenCV SDK as早些时候我添加了 OpenCV SDK 中提到的 CMakeLists.txt 作为

cmake_minimum_required(VERSION 3.6)

 # dummy target to bring libc++_shared.so into packages
 add_library(opencv_jni_shared STATIC dummy.cpp)

and a dummmy.cpp file that may include "libc++_shared.so" in the apk.以及可能在 apk 中包含“libc++_shared.so”的 dummmy.cpp 文件。 Yet No results.然而没有结果。

Please help with a solution.请帮助解决。

Try to add the following line into your build.gradle file from the app section.尝试将以下行添加到 app 部分的 build.gradle 文件中。

arguments "-DANDROID_STL=c++_shared"参数“-DANDROID_STL=c++_shared”

It must be added to the externalNativeBuild sub-section.它必须添加到 externalNativeBuild 子部分。

android {
    .
    .
    defaultConfig {
        .
        externalNativeBuild {
            cmake {
                .
                arguments "-DANDROID_STL=c++_shared"
            }
        }
    }
}

btw: Ranjit Vamadevan , I don't see your solution here but you mentioned you found one in your comments directly.顺便说一句: Ranjit Vamadevan ,我在这里没有看到您的解决方案,但您提到您直接在评论中找到了一个。 I can not answer there.我不能回答那里。 Could you please share it with us too?你也可以和我们分享一下吗?

This solved it for me: Put the content of the C:\\Users%username%\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\llvm-libc++\\libs%platform%\\libc++_shared.so file in your jniLibs folder(s).这为我解决了:把 C:\\Users%username%\\AppData\\Local\\Android\\sdk\\ndk-bundle\\sources\\cxx-stl\\llvm-libc++\\libs%platform%\\libc++_shared 的内容jniLibs 文件夹中的 .so 文件。

Found here: https://github.com/bkaradzic/bgfx/issues/1122#issuecomment-296356682在这里找到: https : //github.com/bkaradzic/bgfx/issues/1122#issuecomment-296356682

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM