我尝试使用以下设置在Ubuntu上使用Qt对Raspberry Pi的OpenCV进行交叉编译:
我已经从GitHub下载了opencv和opencv_contrib文件夹,并将自定义arm-raspberrypi.cmake
放在opencv/platforms/linux
arm-raspberrypi.cmake
set( CMAKE_SYSTEM_NAME Raspberry Pi )
set( CMAKE_SYSTEM_PROCESSOR arm )
set( SYSROOT /opt/Toolchain/RaspberryPi/sysroot )
set( CMAKE_C_COMPILER /opt/Toolchain/RaspberryPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc )
set( CMAKE_CXX_COMPILER /opt/Toolchain/RaspberryPi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${SYSROOT} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -march=armv6 -mfloat-abi=hard -mfpu=vfp" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${SYSROOT} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -march=armv6 -mfloat-abi=hard -mfpu=vfp" )
我的cmake命令如下:
cmake \
-D CMAKE_TOOLCHAIN_FILE=/home/daniel/Schreibtisch/Test/opencv/platforms/linux/arm-raspberrypi.cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/home/daniel/Schreibtisch/OpenCVTest \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D Qt5Core_DIR=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/lib/cmake/Qt5Core \
-D Qt5Gui_DIR=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/lib/cmake/Qt5Gui \
-D Qt5OpenGL_DIR=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/lib/cmake/Qt5OpenGL \
-D Qt5Widgets_DIR=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/lib/cmake/Qt5Widgets \
-D Qt5Test_DIR=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/lib/cmake/Qt5Test \
-D Qt5Concurrent_DIR=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/lib/cmake/Qt5Concurrent \
-D QT_QMAKE_EXECUTABLE=/opt/Toolchain/RaspberryPi/sysroot/usr/local/RaspberryQt/bin \
-D WITH_OPENGL=ON \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D WITH_TBB=OFF \
-D BUILD_EXAMPLES=OFF ..
但是我在make
期间遇到了这个错误
Scanning dependencies of target libpng
[ 13%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngwutil.c.o
In file included from /home/daniel/Schreibtisch/Test/opencv/3rdparty/libpng/pngpriv.h:913:0,
from /home/daniel/Schreibtisch/Test/opencv/3rdparty/libpng/pngwutil.c:14:
/home/daniel/Schreibtisch/Test/opencv/3rdparty/libpng/pngstruct.h:30:18: fatal error: zlib.h: No such file or directory
#include "zlib.h"
^
compilation terminated.
但是该文件位于/opt/Toolchain/RaspberryPi/sysroot/usr/include/
。这是怎么回事?