我可以跳过 cmake 编译器测试或避免 "error: unrecognized option ' -rdynamic'"

标签 c cmake cross-compiling

用于 ARM 目标系统的 cmake(在 Windows 上)的编译选项但是当我运行配置时它开始编译器测试:

CMake Error at D:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "D:/Program Files/yagarto/bin/arm-none-eabi-gcc.exe" is not
  able to compile a simple test program.

  It fails with the following output:

   Change Dir: D:/merge/complex/build/CMakeFiles/CMakeTmp



  Run Build Command:D:/PROGRA~1/YAGART~1/bin/make.exe "cmTryCompileExec/fast"

  D:/PROGRA~1/YAGART~1/bin/make.exe -f
  CMakeFiles/cmTryCompileExec.dir/build.make
  CMakeFiles/cmTryCompileExec.dir/build

  make.exe[1]: Entering directory
  `D:/merge/complex/build/CMakeFiles/CMakeTmp'

  "D:/Program Files/CMake 2.8/bin/cmake.exe" -E cmake_progress_report
  D:/merge/complex/build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o

  "D:/Program Files/yagarto/bin/arm-none-eabi-gcc.exe" -o
  CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c
  D:/merge/complex/build/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTryCompileExec

  "D:/Program Files/yagarto/bin/arm-none-eabi-gcc.exe"
  "CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o" -o cmTryCompileExec
  -rdynamic 

  arm-none-eabi-gcc.exe: error: unrecognized option '-rdynamic'

  make.exe[1]: *** [cmTryCompileExec] Error 1

使用 Yagatdo 4.6.* 交叉编译工具链

如何跳过此测试或修复我遇到的 -rdynamic 错误?

最佳答案

可以设置CMAKE_<LANG>_COMPILER_WORKS为 true 以抑制对该语言的进一步编译器检查。

set(CMAKE_C_COMPILER_WORKS 1)

关于我可以跳过 cmake 编译器测试或避免 "error: unrecognized option ' -rdynamic'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10599038/

相关文章:

c++ - 如何使用 GTK+ 设置 CMakeLists?

linux - 如何在 Linux 上编译 Intel Mac 二进制文件?

cmake - CMake 的 find_library 是否搜索 LD_LIBRARY_PATH?

c - 如何捕获哪个 TreeView 节点被单击

c - 为什么这段代码会出错?

c - 这是在 C 中适当使用 const 限定符吗?

c++ - WSL 中 QT 的动态链接不起作用但在 docker 容器中工作

android - 如何在Android上使用strace?

c - 裸机 C 代码(微处理器固件): simulating changes in hardware registers 的自动化测试

c - 使用二维数组,我的数组没有出现