I'm having problems using native OpenCv 3.0.0 with Android Studio 2.2 with new ndk support. I am using a CMAKE build script. Below is the error I am getting. Am I missing something in my gradel or cmake file? Please let me know.
Error: FAILURE: build failed with exception.
- What went wrong: Execution failed for task ': app: externalNativeBuildDebug'.
Build command failed. An error occurred while executing 'C: \ Users \ User \ AppData \ Local \ Android \ sdk \ cmake \ 3.6.3155560 \ bin \ cmake.exe' with the arguments {--build E: \ OpenCvAndroid \ OPecvTry2CSupport \ app.externalNativeBuild \ cmake \ debug \ mips64 --target native-lib} [1/1] Linking the CXX shared library .. \ obj \ mips64 \ libnative-lib.so FAILED: cmd.exe / C "cd. & C: \ Users \ User \ AppData \ Local \ Android \ sdk \ ndk-bundle \ toolchains \ llvm \ prebuilt \ windows-x86_64 \ bin \ clang ++. Exe -target mips64el-none-linux-android -gcc-toolchain C: / Users / User / AppData / Local / Android / sdk / ndk-bundle / toolchains / mips64el-linux-android-4.9 / prebuilt / windows-x86_64 --sysroot = C: / Users / User / AppData / Local / Android / sdk / ndk-bundle / platform / android- 21 / arch-mips64 -fPIC -g -DANDROID -Functions -funwind-tables -fstack-protector-strong -no- canonical-prefixes -Wa, - noexecstack -Wformat -Werror = format-security -fno-exceptions -fno-rtti -O0 -fno-limit-debug-info -Wl, -bui ld-id -Wl, -warn- shared-textrel -Wl, - fatal-warnings -Wl, - no- undefined -Wl, -z, noexecstack -Qunused-arguments -Wl, -z, relro -Wl, -z, now -shared -Wl, -soname, libnative-lib.so -o .. \ obj \ mips64 \ libnative-lib.so CMakeFiles / native-lib.dir / src / main / cpp / native-lib.cpp.o - llog -lm "C: / Users / User / AppData / Local / Android / SDK / NDK bundle / sources / CXX-STL / gnu-libstdC ++ / 4.9 / LIES / MIPS64 / libgnustl_stati ca" & & CD. " CMakeFiles / native-lib.dir / src / main / cpp / native-lib.cpp.o: In ~Mat': E:/OpenCVSdk/sdk/native/jni/include\opencv2/core/mat.hpp:278: undefined reference to function ~Mat': E:/OpenCVSdk/sdk/native/jni/include\opencv2/core/mat.hpp:278: undefined reference to cv :: fastFree (void *) 'CMakeFiles / native-lib.dir / src / main / cpp / native-lib.cpp.o: In the cv::Mat::release()': E:/OpenCVSdk/sdk/native/jni/include\opencv2/core/mat.hpp:367: undefined reference to function cv::Mat::release()': E:/OpenCVSdk/sdk/native/jni/include\opencv2/core/mat.hpp:367: undefined reference to cv :: Mat :: deallocate () 'clang ++. exe: error: the linker command failed with exit code 1 (use -v to see the call) ninja: build stopped: the subcommand failed.
And my cmake.txt
cmake_minimum_required(VERSION 3.4.1) add_library( native-lib SHARED src/main/cpp/native-lib.cpp ) include_directories(E\:\\OpenCVSdk\\sdk\\native\\jni\\include ) find_library( log-lib log ) target_link_libraries(native-lib ${log-lib} )
And my Gradel build file
{ apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.2" defaultConfig { applicationId "viki.opecvtry2csupport" minSdkVersion 16 targetSdkVersion 24 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { cppFlags "" } } }
vicky source share