9 years, 4 months ago.

Errors building STM32L152RE mbed project with GNU GCC

I have used the export function for the F401RE, exporting to EmBlocks and CoIDE, and they work fine. Both EmBlocks and CoIDE use GNU ARM compiler! I am VERY new to ARM, and spent last 15 years doing mainly PIC and 8051 related projects. So, any help will be appreciated! We are designing 3 STM32 boards, and will be adding them to mbed, and want to have to option of compiling them offline using GNU GCC with EmBlocks and CoIDE. I am however having trouble getting the L152RE project to link with GNU GCC. All files compile OK, but brings an error during linking.

I created a CoIDE and EmBlocks project, and uploaded them to GitHub: https://github.com/modtronix-com/Nucleo_blink_led_ls_L152RE_coide and https://github.com/modtronix-com/Nucleo_blink_led_ls_L152RE_emblocks

The link errors I get are:

Link error with CoIDE

[cc] ..\obj\exit.o: In function `exit': [cc] D:\prj\mbed\projects\Nucleo_blink_led_ls_L152RE_coide\mbed-src\common/exit.c:26: multiple definition of `exit' [cc] c:/program files (x86)/gnu tools arm embedded/4.8 2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7-m\libc.a(lib_a-exit.o):exit.c:(.text.exit+0x0): first defined here [cc] ..\obj\retarget.o:(.data+0x0): undefined reference to `end' [cc] collect2.exe: error: ld returned 1 exit status

Link error with Em:Blocks

.objs\mbed-src\common\exit.o||In function `exit':| D:\prj\mbed\projects\Nucleo_blink_led_ls_L152RE_emblocks\mbed-src\common\exit.c|26|multiple definition of `exit'| .objs\mbed-src\common\retarget.o:(.data._ZZ5_sbrkE4heap+0x0)||undefined reference to `end'|

1 Answer

9 years, 4 months ago.

try building it without TOOLCHAIN_GCC_ARM. Because in retarget.cpp, the end symbol is used for heap, but only with TOOLCHAIN_GCC_ARM. Its probably expecting some certain linker script which defines that symbol.