5

I'm trying to integrate both OpenCV and dlib-android in the NDK. I'm able to get both OpenCV and dlib working in seperate projects, but the project breaks when they both are integrated.

This is my gradle config for dlib

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
    ...
    externalNativeBuild {
        cmake {
            cppFlags "-std=c++11 -frtti -fexceptions"
            arguments "-DANDROID_PLATFORM=android-16",
                    "-DANDROID_TOOLCHAIN=clang",
                    "-DANDROID_STL=c++_shared",
                    "-DANDROID_CPP_FEATURES=rtti exceptions"
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ["src/main/jniLibs/dlib/libs"]
        }
    }
}
...

When I integrate openCV, I get

undefined reference to 'cv::CascadeClassifier::detectMultiScale'

The solution to which according to this answer, is to have the stl as gnustl_shared

dlib with gnustl_shared gives errors like std::exceptions not found.

How do I go forward and integrate both?

I tried to recompile OpenCV with c++_shared on CMake, but ran into

fatal error: iostream: No such file or directory #include

Udit Mukherjee
  • 687
  • 5
  • 20
  • You can't mix and match STLs, unfortunately. They aren't ABI compatible. OpenCV has their own CMake toolchain file. It's possible that theirs isn't compatible with libc++? – Dan Albert Jun 22 '17 at 19:07

0 Answers0