我想使用 cmake 和我从这里下载的预编译 linaro 工具链交叉编译 raspberrypi2:git clone https://github.com/raspberrypi/tools
当我尝试对我的项目执行 cmake 时,出现以下错误:
/myhome/libs/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-
gnueabihf-raspbian-x64//bin/arm-linux-gnueabihf-gcc
--sysroot=/myhome/libs/raspberry/tools/
arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/libc/
CMakeFiles/cmTC_9fb02.dir/testCCompiler.c.o -o cmTC_9fb02 -rdynamic
/myhome/libs/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-
gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../..
/../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o:
No such file or directory
该文件位于以下目录中:
/myhome/libs/raspberry/tools/arm-bcm2708/gcc-linaro-arm-
linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/libc/
usr/lib/arm-linux-gnueabihf
我的 cmake 工具链文件如下所示
set(CMAKE_SYSROOT "/myhome/libs/raspberry/sysroot/")
set(tools "/myhome/libs/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/")
set(CMAKE_C_COMPILER "${tools}/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "${tools}/bin/arm-linux-gnueabihf-g++")
set(CMAKE_EXPORT_COMPILE_COMMANDS=ON)
set(CMAKE_FIND_ROOT_PATH "${CMAKE_SYSROOT}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
sysroot 目录是我安装树莓派映像的位置。我有点困惑这应该是覆盆子图像的根还是 linaro 工具链的路径。
谢谢你的帮助