Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 6 months ago.
Offline GCC-ARM-Embedded compiler error due to double definitions of nano.specs ?
I export a project from mbed online to offline GCC-ARM-Embedded. I got the following error:
arm-none-eabi-gcc: fatal error: c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/nano.specs: attempt to rename spec 'link' to already defined spec 'nano_link' compilation terminated. make[1]: *** [Nucleo_LoRaPHY.elf] Error 1 make: *** [all] Error 2
After searching similar issues and work around, I found it maybe related to the nano.specs in LD / LD_FLAGS setup.
- [Github RIOT](https://github.com/RIOT-OS/RIOT/pull/5054)
- [NXP forum](https://community.nxp.com/thread/356881)
=“Makefile"
LD = 'arm-none-eabi-gcc' '-Wl,--gc-sections' '-Wl,--wrap,main' '-Wl,--wrap,_malloc_r' '-Wl,--wrap,_free_r' '-Wl,--wrap,_realloc_r' '-Wl,--wrap,_calloc_r' '-Wl,--wrap,exit' '-Wl,--wrap,atexit' '--specs=nano.specs' '-mcpu=cortex-m0plus' '-mthumb' ELF2BIN = 'arm-none-eabi-objcopy' ... LD_FLAGS :=-Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r -Wl,--wrap,_realloc_r -Wl,--wrap,_calloc_r -Wl,--wrap,exit -Wl,--wrap,atexit --specs=nano.specs -mcpu=cortex-m0plus -mthumb ... $(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SCRIPT) +@echo "link: $(notdir $@)" @$(LD) $(LD_FLAGS) -T $(filter %.ld, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) ...
However no matter how I change that flags by removing one of them, it throws out following errors:
link: Nucleo_LoRaPHY.elf /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-fclose.o): In function `_fclose_r': fclose.c:(.text._fclose_r+0x54): undefined reference to `__wrap__free_r' fclose.c:(.text._fclose_r+0x68): undefined reference to `__wrap__free_r' fclose.c:(.text._fclose_r+0x78): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-fflush.o): In function `__sflush_r': fflush.c:(.text.__sflush_r+0x90): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-findfp.o): In function `__sfmoreglue': findfp.c:(.text.__sfmoreglue+0xe): undefined reference to `__wrap__malloc_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-fseeko.o): In function `_fseeko_r': fseeko.c:(.text._fseeko_r+0x9e): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-makebuf.o): In function `__smakebuf_r': makebuf.c:(.text.__smakebuf_r+0x2a): undefined reference to `__wrap__malloc_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-malloc.o): In function `malloc': malloc.c:(.text.malloc+0x8): undefined reference to `__wrap__malloc_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-malloc.o): In function `free': malloc.c:(.text.free+0x8): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-setvbuf.o): In function `setvbuf': setvbuf.c:(.text.setvbuf+0x52): undefined reference to `__wrap__free_r' setvbuf.c:(.text.setvbuf+0x6a): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-ungetc.o): In function `__submore': ungetc.c:(.text.__submore+0x14): undefined reference to `__wrap__malloc_r' ungetc.c:(.text.__submore+0x52): undefined reference to `__wrap__realloc_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-wsetup.o): In function `__swsetup_r': wsetup.c:(.text.__swsetup_r+0x68): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-nano-svfprintf.o): In function `__ssputs_r': nano-vfprintf.c:(.text.__ssputs_r+0x46): undefined reference to `__wrap__malloc_r' nano-vfprintf.c:(.text.__ssputs_r+0xac): undefined reference to `__wrap__realloc_r' nano-vfprintf.c:(.text.__ssputs_r+0xb8): undefined reference to `__wrap__free_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-nano-svfprintf.o): In function `_svfiprintf_r': nano-vfprintf.c:(.text._svfprintf_r+0x1a): undefined reference to `__wrap__malloc_r' /usr/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/libc_nano.a(lib_a-nano-svfscanf.o): In function `__ssrefill_r': nano-vfscanf.c:(.text.__ssrefill_r+0x12): undefined reference to `__wrap__free_r' collect2: error: ld returned 1 exit status make[1]: *** [Nucleo_LoRaPHY.elf] Error 1 make: *** [all] Error 2
Is it a bug of Makefile ? I have tried different gcc-arm-embedded compilers, including 4.9.3 and latest 6.3.1.