用cmake交叉编译无法链接测试

时间:2017-06-27 08:22:08

标签: cmake cross-compiling

我尝试使用CMake(2.8.12.2)交叉编译库(Wt)。我总是得到错误,告诉我它无法编译一个简单的测试程序。 我不知道如何让cmake查看获取目标文件的正确路径。 我的开发和目标平台是Linux。

错误日志如下所示

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /opt/rhl/0.01/sysroots/x86_64-rhlsdk-linux/usr/bin/arm-reed-linux-gnueabi/arm-reed-linux-gnueabi-gcc 
Build flags: ;-O2;-pipe;-g;-feliminate-unused-debug-types;
Id flags: 

The output was:
1
/opt/rhl/0.01/sysroots/x86_64-rhlsdk-linux/usr/libexec/arm-reed-linux-gnueabi/gcc/arm-reed-linux-gnueabi/5.3.0/real-ld: cannot find crt1.o: No such file or directory
/opt/rhl/0.01/sysroots/x86_64-rhlsdk-linux/usr/libexec/arm-reed-linux-gnueabi/gcc/arm-reed-linux-gnueabi/5.3.0/real-ld: cannot find crti.o: No such file or directory
...

这是我的工具链文件。我可以跳过测试(参见CMAKE_C_COMPILER_WORKS),但后来我遇到了类似的问题:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

# Compiler and linker
SET(CMAKE_C_COMPILER "/opt/rhl/0.01/sysroots/x86_64-rhlsdk-linux/usr/bin/arm-reed-linux-gnueabi/arm-reed-linux-gnueabi-gcc")
SET(CMAKE_CXX_COMPILER "/opt/rhl/0.01/sysroots/x86_64-rhlsdk-linux/usr/bin/arm-reed-linux-gnueabi/arm-reed-linux-gnueabi-g++")
SET(COMPILE_FLAGS " -march=armv7-a -marm -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/rhl/0.01/sysroots/cortexa8hf-neon-reed-linux-gnueabi")
SET(CMAKE_EXE_LINKER_FLAGS " -O2 -v -o  --sysroot=/opt/rhl/0.01/sysroots/cortexa8hf-neon-reed-linux-gnueabi ")

# Paths
SET(CMAKE_PREFIX_PATH /opt/rhl/0.01/sysroots/cortexa8hf-neon-reed-linux-gnueabi/usr/)
SET(CMAKE_SYSROOT /opt/rhl/0.01/sysroots/cortexa8hf-neon-reed-linux-gnueabi/)
SET(CMAKE_FIND_ROOT_PATH /opt/rhl/0.01/sysroots/cortexa8hf-neon-reed-linux-gnueabi/)

SET(CMAKE_COLOR_MAKEFILE ON)
set(SHARED_LIBS OFF)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# skip the compiler tests 
# set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")
# set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")

这是我系统的树形图。我修剪它以显示相关部分。

/opt/rhl/0.01/sysroots
├── cortexa8hf-neon-reed-linux-gnueabi
│   ├── bin
│   ├── lib
│   ├── usr
│   │   ├── bin
│   │   ├── include
│   │   ├── lib
│   │   │   ├── crt1.o -> cmake cannot find this file
│   │   │   ├── crti.o -> cmake cannot find this file
│   │   ├── share
│   │   └── src
│   │           ├── gcc-runtime
│   │           │   └── 5.3.0-r0
└── x86_64-rhlsdk-linux
    ├── lib
    ├── sbin
    ├── usr
    │   ├── bin
    │   │   │   ├── arm-reed-linux-gcc -> ../arm-reed-linux-gnueabi/arm-reed-linux-gnueabi-gcc
    │   │   ├── arm-reed-linux-gnueabi
    │   │   │   ├── arm-reed-linux-gnueabi-gcc  -> The C compiler
    │   ├── include
    │   ├── lib
    │   ├── libexec

0 个答案:

没有答案
相关问题