关于cmake is not able to compile a simple test program

来源:互联网 发布:二胡软件 编辑:程序博客网 时间:2024/06/05 16:46

指定了交叉编译

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_FIND_ROOT_PATH "/opt/mips/eldk4.1/usr/bin")
set(CMAKE_C_COMPILER "${CMAKE_FIND_ROOT_PATH}/mips_4KC-gcc")

但报错compile tools can not be able to build a simple program

如下可解决

You don't have to write a toolchain file for every piece of software you want to build, the toolchain files are per target platform, i.e. if you are building several software packages all for the same target platform, you have to write only one toolchain file and you can use this for all packages.

If your compiler is not able to build a simple program by default without special flags or files (e.g. linker scripts or memory layout files), the toolchain file as shown above doesn't work. Then you have to force the compiler:

INCLUDE(CMakeForceCompiler)# this one is importantSET(CMAKE_SYSTEM_NAME eCos)# specify the cross compilerCMAKE_FORCE_C_COMPILER(arm-elf-gcc GNU)CMAKE_FORCE_CXX_COMPILER(arm-elf-g++ GNU)# where is the target environment SET(CMAKE_FIND_ROOT_PATH  /home/alex/src/ecos/install )# search for programs in the build host directoriesSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)# for libraries and headers in the target directoriesSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
0 0
原创粉丝点击