GithubHelp home page GithubHelp logo

Comments (5)

Luca96 avatar Luca96 commented on April 28, 2024 1

Hi @alexander-zou, maybe your problem is about the standard c++ library.
What i mean is that OpenCV use the gnustl_shared standard library, so if you don't use this library in your android project, the compiler will complain with every methods that has string or vector as argument.

If you use CMake you can add this snippet in your build.gradle under android->defaultConfig:

externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -fexceptions"
                abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'  //keep only supported arch by your app
                arguments "-DANDROID_PLATFORM=android-15",  // change with your min api level
                        "-DANDROID_TOOLCHAIN=clang",
                        "-DANDROID_STL=gnustl_shared", // the standard lib
                        "-DANDROID_CPP_FEATURES=rtti exceptions"
            }
        }

and in your CMakeLists you have to add something like this:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -std=gnustl")

that is, i hope it works!

from learnopencv.

calicratis19 avatar calicratis19 commented on April 28, 2024 1

@Luca96 your previous comment worked for me finally. This was indeed an issue with gnu and libc++ stl. But I had to modify this
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -std=gnustl")

to

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -std=gnu++11")

from learnopencv.

alexander-zou avatar alexander-zou commented on April 28, 2024

I am desperate with the same problem in my android project, may I ask how did you solve it? Thank you so much!

from learnopencv.

calicratis19 avatar calicratis19 commented on April 28, 2024

Hi, from the official docs (https://developer.android.com/ndk/guides/cpp-support.html) the gnustl is deprecated from ndk16 and will be removed.

gnustl

The GNU C++ Library is called gnustl on Android to differentiate it from the system runtime. This runtime is the libstdc++ available on a GNU/Linux system.

This runtime is tightly coupled to GCC, which is no longer supported in the NDK. As such, it has not received updates for several releases. The version in the NDK only supports C++11, and some portions of this library are incompatible with Clang.

Note: This library will be deprecated and removed in a future NDK release. Beginning with NDK r16, you should use libc++ instead.

I'm having the same issue for couple of days now.

from learnopencv.

Luca96 avatar Luca96 commented on April 28, 2024

Maybe you can try to recompile OpenCV with libc++ instead of gnustl.

from learnopencv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.