报错信息
1
2
3
4
5
6
7
8
9
10
| ld: error: cannot open crt1.o: No such file or directory
ld: error: cannot open crti.o: No such file or directory
ld: error: cannot open crtbegin.o: No such file or directory
ld: error: cannot open crtend.o: No such file or directory
ld: error: cannot open crtn.o: No such file or directory
ld: error: cannot find -lgcc
ld: error: cannot find -lgcc_s
ld: error: cannot find -lc
ld: error: cannot find -lgcc
ld: error: cannot find -lgcc_s
|
需要配置sysroot
1
| gcc --sysroot=/path/to/toolchain/sysroot
|
/path/to/toolchain/sysroot
是系统头文件和库的位置
cmake 2.8添加sysroot方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # compiler
set(CMAKE_C_COMPILER /path/to/arm-none-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /path/to/arm-none-linux-gnueabi-g++)
# sysroot location
set(MYSYSROOT /path/to/sysroots/cortexa7-vfp-neon-telechips-linux-gnueabi)
# compiler/linker flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${MYSYSROOT}" CACHE INTERNAL "" FORCE)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${MYSYSROOT}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${MYSYSROOT}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${MYSYSROOT}" CACHE INTERNAL "" FORCE)
# cmake built-in settings to use find_xxx() functions
set(CMAKE_FIND_ROOT_PATH "${MYSYSROOT}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
cmake 3.0之后的版本可以使用CMAKE_SYSROOT