0

刚开始使用 CMake 交叉编译 ARM cortex M7 的库。

cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../.CMake/toolchain_armcortexm7.cmake -DOQS_USE_OP ENSSL=OFF ..

运行 cmake 构建时,它首先检查编译器是否能够“编译一个简单的测试程序”,出现以下错误:

/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
/build/newlib-CVVEyx/newlib-3.3.0/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'

这个解决方案应该解决哪个

add_compile_options(--specs=nosys.specs)

但是这个选项显然没有传递给编译器测试 [2/2]。为什么?

Run Build Command(s):/usr/bin/ninja cmTC_0edfd && [1/2] Building C object CMakeFiles/cmTC_0edfd.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_0edfd
FAILED: cmTC_0edfd
: && /usr/bin/arm-none-eabi-gcc    CMakeFiles/cmTC_0edfd.dir/testCCompiler.c.o  -o cmTC_0edfd   && :
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
/build/newlib-CVVEyx/newlib-3.3.0/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib/libc/stdlib/exit.c:64: undefined reference to `_exit'

如果我拼错了编译器选项,测试 [1/2] 将失败并包含正确的标志

Run Build Command(s):/usr/bin/ninja cmTC_65be3 && [1/2] Building C object CMakeFiles/cmTC_65be3.dir/testCCompiler.c.o
    FAILED: CMakeFiles/cmTC_65be3.dir/testCCompiler.c.o
    /usr/bin/arm-none-eabi-gcc   --specs=nosys. -mcpu=cortex-m7 -g3 -DSTM32F746xx -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -mfpu=fpv5-sp-d16 -mfloat-abi=soft -mthumb -o CMakeFiles/cmTC_65be3.dir/testCCompiler.c.o   -c testCCompiler.c
    arm-none-eabi-gcc: fatal error: cannot read spec file 'nosys.': No such file or directory
4

1 回答 1

1

显然没有通过编译器测试 [2/2]。为什么?

Building C object...如您的输出所示,它被传递给编译器。它没有传递给链接器Linking ...。你做了compile_options,没有link_options

于 2021-08-05T08:31:44.280 回答