我正在尝试按照https://github.com/HesselM/rpicross_notes
上的说明在Ubuntu 16.04上为Raspberry Pi Zero建立一个交叉编译环境。工具链文件中有一个变量RPI_ROOTFS,用于指定在何处查找Raspberry PI文件系统的副本。原始说明中的值为/ home / pi / rootfs。我不想对环境中的值进行硬编码,所以我更改了
set( RPI_ROOTFS /home/pi/rpi/rootfs )
对此
set( RPI_ROOTFS "/home/pi/rootfs" CACHE FILEPATH "Raspberry Pi filesystem root")
然后我使用以下命令来配置CMake以构建Raspberry PI用户区
cmake \
-D CMAKE_ASM_COMPILER=/usr/local/bin/rpizero-gcc \
-D CMAKE_TOOLCHAIN_FILE=/home/dsnowdon/rpi-cross/rpicross_notes/rpi-generic-toolchain.cmake \
-D CMAKE_BUILD_TYPE=Release \
-D RPI_ROOTFS=/home/dsnowdon/rpi-cross/rootfs \
/home/dsnowdon/rpi-cross/rootfs/usr/src/userland
但是,在生成构建文件时,我在此阶段看到一个失败:运行构建命令:“ / usr / bin / make”“ cmTC_fac33 / fast”
在CMakeCache.txt中,我可以看到RPI_ROOTFs的值已正确设置:
RPI_ROOTFS:FILEPATH=/home/dsnowdon/rpi-cross/rootfs
但是在CMakeError.log中,我可以看到以下内容。
/usr/local/bin/rpizero-gcc -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/local/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/local/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/local/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/local/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include/arm-linux-gnueabihf -isystem /home/dsnowdon/rpi-cross/rootfs/usr/include -isystem /home/dsnowdon/rpi-cross/rootfs/usr/local/include -Wl,-rpath /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf -Wl,-rpath /home/pi/rpi/rootfs/lib/arm-linux-gnueabihf CMakeFiles/cmTC_fac33.dir/testCCompiler.c.o -o cmTC_fac33 -rdynamic
rpizero-gcc: error: /home/pi/rpi/rootfs/usr/lib/arm-linux-gnueabihf: No such file or directory
rpizero-gcc: error: /home/pi/rpi/rootfs/lib/arm-linux-gnueabihf: No such file or directory
CMakeFiles/cmTC_fac33.dir/build.make:97: recipe for target 'cmTC_fac33' failed
make[1]: *** [cmTC_fac33] Error 1
看起来某些地方使用了缓存中RPI_ROOTFS的值,而其他地方使用了默认值
例如,工具链文件中的该值似乎已使用RPI_ROOTFS的缓存版本
# setup RPI include/lib/pkgconfig directories for compiler/pkgconfig
set( RPI_INCLUDE_DIR "${RPI_INCLUDE_DIR} -isystem ${RPI_ROOTFS}/usr/include/arm-linux-gnueabihf")
set( RPI_INCLUDE_DIR "${RPI_INCLUDE_DIR} -isystem ${RPI_ROOTFS}/usr/include")
set( RPI_INCLUDE_DIR "${RPI_INCLUDE_DIR} -isystem ${RPI_ROOTFS}/usr/local/include")
这似乎使用了默认值
set( RPI_LIBRARY_DIR "${RPI_LIBRARY_DIR} -Wl,-rpath ${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf")
set( RPI_LIBRARY_DIR "${RPI_LIBRARY_DIR} -Wl,-rpath ${RPI_ROOTFS}/lib/arm-linux-gnueabihf")
第二组配置紧随第一组配置之后,所以我看不到要使用什么不同的值
如果我在工具链文件中为我的环境(/ home / dsnowdon / rpi-cross / rootfs)硬编码RPI_ROOTFS的值,那么一切正常
是什么原因造成的?
作为参考,这是完整的工具链文件:
set( RPI_ROOTFS "/home/pi/rpi/rootfs" CACHE FILEPATH "Raspberry Pi filesystem root")
set( CMAKE_FIND_ROOT_PATH ${RPI_ROOTFS} )
# compilers
set( CMAKE_C_COMPILER "/usr/local/bin/rpizero-gcc" CACHE FILEPATH "")
set( CMAKE_CXX_COMPILER "/usr/local/bin/rpizero-g++" CACHE FILEPATH "")
set( CMAKE_AR "/usr/local/bin/rpizero-ar" CACHE FILEPATH "")
set( CMAKE_RANLIB "/usr/local/bin/rpizero-ranlib" CACHE FILEPATH "")
# Platform
set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_SYSTEM_VERSION 1 )
set( CMAKE_SYSTEM_PROCESSOR arm )
set( CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf )
set( FLOAT_ABI_SUFFIX "hf" )
add_definitions( "-mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -marm" )
# setup RPI include/lib/pkgconfig directories for compiler/pkgconfig
set( RPI_INCLUDE_DIR "${RPI_INCLUDE_DIR} -isystem ${RPI_ROOTFS}/usr/include/arm-linux-gnueabihf")
set( RPI_INCLUDE_DIR "${RPI_INCLUDE_DIR} -isystem ${RPI_ROOTFS}/usr/include")
set( RPI_INCLUDE_DIR "${RPI_INCLUDE_DIR} -isystem ${RPI_ROOTFS}/usr/local/include")
set( RPI_LIBRARY_DIR "${RPI_LIBRARY_DIR} -Wl,-rpath ${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf")
set( RPI_LIBRARY_DIR "${RPI_LIBRARY_DIR} -Wl,-rpath ${RPI_ROOTFS}/lib/arm-linux-gnueabihf")
set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf/pkgconfig" )
set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/share/pkgconfig" )
set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/opt/vc/lib/pkgconfig" )
set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:/home/dsnowdon/rpi-cross/ros/src_cross/devel_isolated" )
# C/CXX flags
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RPI_INCLUDE_DIR}" CACHE STRING "" FORCE)
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${RPI_INCLUDE_DIR}" CACHE STRING "" FORCE)
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${RPI_LIBRARY_DIR}" CACHE STRING "" FORCE)
# Pkg-config settings
set( PKG_CONFIG_EXECUTABLE "/usr/bin/pkg-config" CACHE FILEPATH "")
set( ENV{PKG_CONFIG_DIR} "" CACHE FILEPATH "")
set( ENV{PKG_CONFIG_LIBDIR} "${RPI_PKGCONFIG_LIBDIR}" CACHE FILEPATH "")
set( ENV{PKG_CONFIG_SYSROOT_DIR} "${RPI_ROOTFS}" CACHE FILEPATH "")
# Python2.7
set( PYTHON_EXECUTABLE "/usr/bin/python2.7" CACHE STRING "")
set( PYTHON_LIBRARY_DEBUG "${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf/libpython2.7.so" CACHE STRING "")
set( PYTHON_LIBRARY_RELEASE "${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf/libpython2.7.so" CACHE STRING "")
set( PYTHON_LIBRARY "${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf/libpython2.7.so" CACHE STRING "")
set( PYTHON_INCLUDE_DIR "${RPI_ROOTFS}/usr/include/python2.7" CACHE STRING "")
set( PYTHON2_NUMPY_INCLUDE_DIRS "${RPI_ROOTFS}/usr/lib/python2.7/dist-packages/numpy/core/include" CACHE STRING "")
set( PYTHON2_PACKAGES_PATH "${RPI_ROOTFS}/usr/local/lib/python2.7/site-packages" CACHE STRING "")
# Boost
set( BOOST_LIBRARYDIR "${RPI_ROOTFS}/usr/lib/arm-linux-gnueabihf/" CACHE STRING "")
# OpenCV
set( OpenCV_DIR "${RPI_ROOTFS}/usr/share/OpenCV/" CACHE STRING "")
# Userland / VideoCore
set( USERLAND_DIR "${RPI_ROOTFS}/usr/src/userland" CACHE STRING "")