This process explains how to compile shared libs of opencv and contrib modules from sources for Android ABI abi-armeabi-v7a
.
##Requirements
- Sources for opencv-3.4.1
- Sources for opencv_contrib-3.4.1
- CMake 3.11.3
- mingw-w64 x86_64-7.3.0-posix-seh-rt_v5-rev0
- Android ndk
- Extract opencv-3.4.1 inside
opencv/opencv-3.4.1
- Extract opencv_contrib-3.4.1 inside
opencv/opencv_contrib-3.4.1
- In CMake (cmake-gui) input Where is the source folder:
opencv/opencv-3.4.1
- In CMake (cmake-gui) input Where to build the binaries:
opencv/build_android_arm
- Remove line 1090 (
android_get_compatible_target(android_sdk_target_status ${ANDROID_NATIVE_API_LEVEL} ${ANDROID_SDK_TARGET} 11)
from opencv/opencv-3.4.1CMakeLists.txt (see opencv/opencv#10929) - Add ANDROID_NDK = android/sdk/ndk-bundle
- Add ANDROID_NATIVE_API_LEVEL = 16
- Add ANDROID_NDK_HOST_X64 = 1
- Configure
- With MinGW Makefiles generator.
- Specify toolchain file for cross-compiling: android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake.
- Wait for configuration..
- Change ANDROID_EXECUTABLE = android/sdk/tools/android.bat
- Change OPENCV_EXTRA_MODULES_PATH = opencv/opencv_contrib-3.4.1/modules
- Change BUILD_ANDROID_EXAMPLES = 0
- Change BUILD_DOCS = 0
- Change BUILD_TESTS = 0
- Change BUILD_PERF_TESTS = 0
- Change ENABLE_PRECOMPILED_HEADERS = 0
- Change ENABLE_CXX11 = 1
- Change BUILD_SHARED_LIBS = 1
- Change WITH_CAROTENE = 0
- Change BUILD_ZLIB = 1
- Change BUILD_JAVA = 0
- Configure
- Generate
- Open a command line at
opencv/build_android_arm
- Run
mingw32-make
and wait for compile process. - Run
mingw32-make install
- Shared libs should be at
opencv/build_android_arm/install/sdk/native/libs/armeabi-v7a
- Header files should be at
opencv/build_android_arm/install/sdk/native/jni/include
It appears that this is working now, according to @ogero