CMake-“错误:无法识别的选项'-rdynamic'”

时间:2019-12-15 10:20:35

标签: cmake

我正在尝试使用CMake构建我的个人项目。但是,这样做时会收到以下错误消息:

$ cmake ../somePath/ -DCMAKE_C_COMPILER='/home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0'

-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0
-- Check for working C compiler: /home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0 -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/John/Desktop/uav/software/firmware/build/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_2b780/fast"
    /usr/bin/make -f CMakeFiles/cmTC_2b780.dir/build.make CMakeFiles/cmTC_2b780.dir/build
    make[1]: Entering directory '/home/John/somePath/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_2b780.dir/testCCompiler.c.o
    /home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0    -o CMakeFiles/cmTC_2b780.dir/testCCompiler.c.o   -c /home/John/somePath/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_2b780
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2b780.dir/link.txt --verbose=1
    /home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0      -rdynamic CMakeFiles/cmTC_2b780.dir/testCCompiler.c.o  -o cmTC_2b780 
    avr-gcc-7.3.0: error: unrecognized command line option '-rdynamic'
    CMakeFiles/cmTC_2b780.dir/build.make:97: recipe for target 'cmTC_2b780' failed
    make[1]: *** [cmTC_2b780] Error 1
    make[1]: Leaving directory '/home/John/somePath/build/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_2b780/fast' failed
    make: *** [cmTC_2b780/fast] Error 2




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt


-- Configuring incomplete, errors occurred!
See also "/home/John/somePath/build/CMakeFiles/CMakeOutput.log".
See also "/home/John/somePath/build/CMakeFiles/CMakeError.log".

它抱怨它不知道-rdynamic选项。 我发现multiple very old posts telling this is a bug of CMake

当今是否有此修复程序?

这是我的CMakeLists.txt文件:

SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR avr)
SET(CMAKE_CROSSCOMPILING 1)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

cmake_minimum_required(VERSION "3.5")

#overwrite default gcc compiler
set(CMAKE_C_COMPILER "/home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-gcc-7.3.0")
#overwrite default linker
set(CMAKE_LINKER "/home/John/Downloads/arduino-1.8.10-linux64/arduino-1.8.10/hardware/tools/avr/bin/avr-ld")
SET(CWARN "-Wall -Wstrict-prototypes")
SET(CTUNING "-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums")

...

add_subdirectory(test)

...
)

0 个答案:

没有答案