c - CMake 生成链接器不喜欢的 Makefile
问题描述
我正在尝试使用 CMake 对构建系统进行现代化改造。当我尝试编译程序时,make
我得到了这个输出
$ cmake -DCMAKE_TOOLCHAIN_FILE="../armgcc.cmake" .. && make
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/arm-none-eabi-g++
-- Check for working CXX compiler: /usr/bin/arm-none-eabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: ~/cmake_test/build
Scanning dependencies of target testproj
[ 50%] Building C object CMakeFiles/testproj.dir/main.c.obj
[100%] Linking C executable testproj
arm-none-eabi-gcc: fatal error: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/nosys.specs: attempt to rename spec 'link_gcc_c_sequence' to already defined spec 'nosys_link_gcc_c_sequence'
compilation terminated.
make[2]: *** [CMakeFiles/testproj.dir/build.make:84: testproj] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/testproj.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
和CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(testproj VERSION 0.1.0)
add_executable(testproj main.c)
和armgcc.cmake
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nosys.specs")
什么是link_gcc_sequence
and nosys_link_gcc_sequence
,我应该如何构建我的 CMakeLists 以避免重命名它们?
解决方案
推荐阅读
- java - 创建重试模板以重试连接超时和读取超时
- c# - Unity:如何将相机沿切平面定向到球体?
- php - Laravel 发布带有 nodejs MethodNotAllowedHttpException 405 错误的帖子
- angular - 如何使用具有 7/8 角度的语言环境和 fullCalendar
- java - java - 当没有显示错误时,如何修复未在java中执行的main方法?
- c++ - 如何在 C++ 中实现静态类?
- python - 使用另一个数组/列表的 Python 索引
- flutter - 当我向上滚动时,如何使 sliverAppBar 只显示缩小的条(浮动:真)
- sql - 使用没有 FK 且在所有表中具有相同 id 的聚合函数加入 2 个以上的表
- python - 通过其中一个中的重复元素过滤两个不规则列表