Create native openCV sources with Android Studio and NDK

I am trying to include some native cpp sources in my android app. I am using Android Studio 1.0 with gradle build system. I have three modules: my android application, android opencv libs, cpp sources (in jni folder)

The build process gives me the following error:

    D:\NVPACK\android-ndk-r10c\sources\cxx-stl\gnu-libstdc++\4.9\include\bits\stl_pair.h
    Error:(96, 12) error: redefinition of 'struct std::pair<_T1, _T2>'
    Error:(214, 5) error: redefinition of 'template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
    ... and some other redefinitions with some other errors in other files.

It appears that the include paths are partially incorrect or that there are duplicate headers in the NDK (stl_pair.h). This is my build.gradle file:

apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"

    ndk{
        moduleName "Native"
        cFlags  "-I'D:\\OpenCV-2.4.10-android-sdk\\sdk\\native\\jni\\include' " +
                "-I'D:\\NVPACK\\android-ndk-r10c\\sources\\cxx-stl\\gnu-libstdc++\\4.9\\include' " +
                "-I'D:\\NVPACK\\android-ndk-r10c\\sources\\cxx-stl\\gnu-libstdc++\\4.9\\libs\\armeabi-v7a\\include'"
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}

In cFlags, I point to openCV sources and standard C ++ sources, as described here . This works fine to the above error.

I only have a basic understanding of the whole build process when working with cpp sources, since I usually work with C # .net or android (without native sources).

, ndk-build .so , . . - ?

edit: eclipse . , - , .

+4

Source: https://habr.com/ru/post/1569838/


All Articles