How to build opencv 3.1.0 for android with GCC 4.9 and c++_shared ?
I want to compile opencv 3.1.0 for android using gcc++ 4.9 and c++_shared. I use the most recent https://github.com/opencv/opencv/blob...
My batch build file looks like this:
@echo off set ROOT=%~dp0 set PATH=C:\Tools\Python34;C:\Tools\cmake;C:\Tools\cmake\bin; set ANDROID_NDK=D:\Jobo.TV\Android\NDK set ANDROID_SDK=D:\Jobo.TV\Android\SDK set OPENCV_ROOT=D:\Jobo.TV\Sources\opencv-3.1.0 echo Android NDK path : %ANDROID_NDK% echo OpenCV source root :%OPENCV_ROOT%
cd d:\Temp\armeabi-v7a cmake.exe -G"MinGW Makefiles" -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_NATIVE_API_LEVEL=android-15 -DCMAKE_TOOLCHAIN_FILE="%ROOT%\android.toolchain.cmake" -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows-x86_64\bin\make.exe" %OPENCV_ROOT%
cmake.exe --build .
The most recent android.toolchain.cmake file contains a mix between gnustl_shared and libc++_static - so the resulting libs cannot be linked because of missing references (std::__throw_length_error or other C++)
I guess the bug comes from android.toolchain.cmake...
elseif( ANDROID_STL MATCHES "c\+\+" ) set( ANDROID_EXCEPTIONS ON ) set( ANDROID_RTTI ON ) set( __libstl "${ANDROID_NDK}/sources/cxx-stl/llvm-libc++" ) set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libc++_static.a" ) set( __libgnustl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" ) set( ANDROID_STL_INCLUDE_DIRS "${__libgnustl}/include" "${__libgnustl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libgnustl}/include/backward" ) else()