$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ mkdir build-android && cd build-android
$ cmake -DCMAKE_TOOLCHAIN_FILE=/home/lqian/Android/Sdk/ndk/20.0.5594570/build/cmake/android.toolchain.cmake -DANDROID_NDK=/home/lqian/Android/Sdk/ndk/20.0.5594570/ ../ -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_ABI=armeabi-v7a
$ make -j4
$ $ ls lib/armeabi-v7a/ -l
total 54864
-rw-rw-r--. 1 lqian lqian 28169394 Aug 29 05:01 libopencv_core.a
-rw-rw-r--. 1 lqian lqian 2778042 Aug 29 05:02 libopencv_imgcodecs.a
-rw-rw-r--. 1 lqian lqian 25225452 Aug 29 05:02 libopencv_imgproc.a
#此处的CMAKE_TOOLCHAIN_FILE一定是NDK目录下的,
opencv自带的编译报错
CMake Error at platforms/android/android.toolchain.cmake:628 (message):
Could not find any working toolchain in the NDK. Probably your Android NDK
is broken.
Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeDetermineSystem.cmake:93 (include)
CMakeLists.txt:127 (project)