1.安装交叉编译工具gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu。
2.解压opencv库,在目录中新建build
3.进入build目录,打开终端,输入命令:
cmake ../ -D CMAKE_C_COMPILER=/home/KAS-300/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -D CMAKE_CXX_COMPILER=/home/KAS-300/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -D CMAKE_AR=/home/KAS-300/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-ar -D CMAKE_TOOLCHAIN_FILE=/media/KAS-300/dd1/opencv-4.5.2/platforms/linux/aarch64-gnu.toolchain.cmake -DBUILD_opencv_core=ON -DBUILD_opencv_imgcodecs=ON -DBUILD_opencv_highgui=ON
其中,只编译部分模块,使用参数-DBUILD_opencv_core=ON
设置交叉编译链-D CMAKE_TOOLCHAIN_FILE=/media/KAS-300/dd1/opencv-4.5.2/platforms/linux/aarch64-gnu.toolchain.cmake
设置交叉编译器CMAKE_C_COMPILER=/home/KAS-300/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -D CMAKE_CXX_COMPILER=/home/KAS-300/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -D CMAKE_AR=/home/KAS-300/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-ar
5.使用make;make install