arm-none-eabi-g++: error: nano.specs: No such file or directory

本文介绍了解决STM32工程在使用GNU工具链进行编译时遇到错误的问题,特别关注了如何正确使用nano.specs选项以避免链接错误。通过将nano.specs加入到链接选项中,可以有效解决编译问题,确保工程顺利构建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近想使用eclipse+Sourcery对STM32的工程进行编译,使用GNU的新建STM32模板工程,bulid是出现如下错误:

17:00:48 **** Incremental Build of configuration Release for project STM32 ****
cs-make all 
'Building target: STM32.elf'
'Invoking: Cross ARM C++ Linker'
arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wall -Wextra  -g -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"STM32.map" --specs=nano.specs -o "STM32.elf"  ./system/src/stm32f1-stdperiph/misc.o ./system/src/stm32f1-stdperiph/stm32f10x_gpio.o ./system/src/stm32f1-stdperiph/stm32f10x_rcc.o  ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o  ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o  ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o  ./system/src/cmsis/system_stm32f10x.o ./system/src/cmsis/vectors_stm32f10x.o  ./src/BlinkLed.o ./src/Timer.o ./src/_write.o ./src/main.o   
arm-none-eabi-g++: error: nano.specs: No such file or directory
cs-make: *** [STM32.elf] Error 1

17:00:54 Build Finished (took 5s.875ms)

搜索这一问题的原因,结果如下:

**** C Libraries usage
+ This toolchain is released with two prebuilt C libraries based on newlib: one is the standard newlib and the other is newlib-nano for code size.
+ To distinguish them, we rename the size optimized libraries as:
  #+BEGIN_EXAMPLE
  libc.a --> libc_s.a
  libg.a --> libg_s.a
  #+END_EXAMPLE  
+ To use newlib-nano, users should provide additional gcc link time option:
  #+BEGIN_EXAMPLE
  --specs=nano.specs
  #+END_EXAMPLE
  + Nano.specs also handles two additional gcc libraries: libstdc++_s.a and libsupc++_s.a, which are optimized for code size.
  + For example:
    #+BEGIN_SRC sh
      arm-none-eabi-gcc src.c --specs=nano.specs $(OTHER_OPTIONS)
    #+END_SRC
  + This option can also work together with other specs options like
    #+BEGIN_EXAMPLE
    --specs=rdimon.specs
    #+END_EXAMPLE
+ Please be noticed that --specs=nano.specs is a linker option. Be sure to include in linker option if compiling and linking are separated.

***** additional newlib-nano libraries usage

Newlib-nano is different from newlib in addition to the libraries' name.
Formatted input/output of floating-point number are implemented as weak symbol.
If you want to use %f, you have to pull in the symbol by explicitly specifying
"-u" command option.
   
  -u _scanf_float
  -u _printf_float

e.g. to output a float, the command line is like: 
$ arm-none-eabi-gcc --specs=nano.specs -u _printf_float $(OTHER_OPTIONS)

For more about the difference and usage, please refer the README.nano in the
source package.

还是没有给出解决的方法,后来发现可在工程设置里面把nano禁止,禁止以后,编译正常。



在使用STM32CubeIDE进行Build时,报错“arm_math.h”找不着,但是“arm_math.h”却存在于Project下的Drivers/CMSIS/DSP/Include文件夹中,这怎么处理? arm-none-eabi-gcc "../Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.c" -mcpu=cortex-m0 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F030xC -c -I../Core/Inc -I../Drivers/STM32F0xx_HAL_Driver/Inc -I../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.d" -MT"Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.o" ../Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_f32.c:29:10: fatal error: arm_math.h: No such file or directory 29 | #include "arm_math.h" | ^~~~~~~~~~~~ compilation terminated. make: *** [Drivers/CMSIS/DSP/Source/MatrixFunctions/subdir.mk:91: Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_f32.o] Error 1 make: *** Waiting for unfinished jobs.... ../Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_q15.c:29:10: fatal error: arm_math.h: No such file or directory 29 | #include "arm_math.h" | ^~~~~~~~~~~~ compilation terminated. make: *** [Drivers/CMSIS/DSP/Source/MatrixFunctions/subdir.mk:91: Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_q15.o] Error 1 ../Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_q31.c:29:10: fatal error: arm_math.h: No such file or directory 29 | #include "arm_math.h" | ^~~~~~~~~~~~ compilation terminated. make: *** [Drivers/CMSIS/DSP/Source/MatrixFunctions/subdir.mk:91: Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_add_q31.o] Error 1 ../Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.c:29:10: fatal error: arm_math.h: No such file or directory 29 | #include "arm_math.h" | ^~~~~~~~~~~~ compilation terminated. make: *** [Drivers/CMSIS/DSP/Source/MatrixFunctions/subdir.mk:91: Drivers/CMSIS/DSP/Source/MatrixFunctions/arm_mat_cmplx_mult_f32.o] Error 1 "make -j12 all" terminated with exit code 2. Build might be incomplete.
07-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值