CMake和预建的linaro工具链:未找到crti.o

时间:2017-02-24 10:20:48

标签: cmake raspberry-pi cross-compiling ld linaro

我想使用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工具链的路径感到有点困惑。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

好的,问题在于

  set(CMAKE_SYSROOT "/myhome/libs/raspberry/sysroot/")

是一个空目录,因为我将jessie映像挂载到此目录,但在重新启动后,挂载不再存在于此目录中。