最近想使用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禁止,禁止以后,编译正常。