文章末尾有编译脚本
源码下载
https://opencv.org/releases/
https://github.com/opencv/opencv/releases
环境搭建
系统:ubuntu 16.04
cmake:3.10.2
ndk:r15c
sudo apt-get install cmake sudo apt-get install gcc sudo apt-get inatall gcc-arm-linux-gnueabihfl g++-arm-linux-gnueabihf缺依赖自行安装
LINUX
动态库
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../install/share/Linux -DBUILD_ZLIB=ON -DWITH_IPP=OFF make -j8 && make install
静态库
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../install/static/Linux -DBUILD_SHARED_LIBS=FALSE -DBUILD_ZLIB=ON -DWITH_IPP=OFF make -j8 && make install
ARM-LINUX
动态库
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_INSTALL_PREFIX=../install/share/Arm-linux -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON -DBUILD_JASPER=ON -DWITH_TIFF=OFF -DWITH_GTK=OFF -DWITH_CUDA=OFF -DWITH_1394=OFF -DWITH_GSTREAMER=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OF make -j8 && make install
静态库
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_INSTALL_PREFIX=../install/static/Arm-linux -DBUILD_SHARED_LIBS=FALSE -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON -DBUILD_JASPER=ON -DWITH_TIFF=OFF -DWITH_GTK=OFF -DWITH_CUDA=OFF -DWITH_1394=OFF -DWITH_GSTREAMER=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DWITH_IPP=OFF make -j8 && make install辅助:可通过readelf -h libopencv_core.a 查看Machine属性,判断库运行平台
shell脚本
pushd build THIS_PATH=$(cd `dirname $0`; pwd) echo "build path : ${THIS_PATH}" #linux rm -irf * cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../install/share/Linux -DBUILD_ZLIB=ON -DWITH_IPP=OFF make -j8 && make install rm -irf * cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../install/static/Linux -DBUILD_SHARED_LIBS=FALSE -DBUILD_ZLIB=ON -DWITH_IPP=OFF make -j8 && make install #arm-linx rm -irf * cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_INSTALL_PREFIX=../install/share/Arm-linux -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON -DBUILD_JASPER=ON -DWITH_TIFF=OFF -DWITH_GTK=OFF -DWITH_CUDA=OFF -DWITH_1394=OFF -DWITH_GSTREAMER=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DWITH_IPP=OFF make -j8 && make install rm -irf * cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_INSTALL_PREFIX=../install/static/Arm-linux -DBUILD_SHARED_LIBS=FALSE -DBUILD_ZLIB=ON -DBUILD_JPEG=ON -DBUILD_PNG=ON -DBUILD_JASPER=ON -DWITH_TIFF=OFF -DWITH_GTK=OFF -DWITH_CUDA=OFF -DWITH_1394=OFF -DWITH_GSTREAMER=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DWITH_IPP=OFF make -j8 && make install pop