undefined reference to `__wrap_exit'

23 Feb 2017

I imported the application Serial-LowPower-Demo in mbed compiler. I have successfully update, compiled and tested the application on my Silicon Labs STK3700. I then exported the project to Simplicity Studio and than imported (File->Import->MCU Project). The compilation is not successful. The error is the following:

Building target: Serial-LowPower-Demo_3.axf
Invoking: GNU ARM C++ Linker
arm-none-eabi-g++ -g -gdwarf-2 -mcpu=cortex-m3 -mthumb -T "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\efm32gg.ld" -L"C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM" -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 -mcpu=cortex-m3 -mthumb --specs=nosys.specs -Xlinker --gc-sections -Xlinker -Map="Serial-LowPower-Demo_3.map" --specs=nano.specs -o Serial-LowPower-Demo_3.axf "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\cmsis_nvic.o" "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\mbed_board.o" "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\mbed_overrides.o" "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\retarget.o" "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\startup_efm32gg.o" "C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\system_efm32gg.o" "./main.o" -lstdc++ -lsupc++ -lm -lnosys -lc -lgcc -lmbed -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
c:/siliconlabs/simplicitystudio/v3/developer/toolchains/gnu_arm/4.8_2013q4/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7-m/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\retarget.o: In function `__cxa_pure_virtual':
retarget.cpp:(.text.__cxa_pure_virtual+0x4): undefined reference to `__wrap_exit'
C:\Users\Antonello\Documents\cancellare\Serial-LowPower-Demo\mbed\TARGET_EFM32GG_STK3700\TOOLCHAIN_GCC_ARM\libmbed.a(mbed_error.o): In function `error':
mbed_error.c:(.text.error+0x12): undefined reference to `__wrap_exit'
collect2.exe: error: ld returned 1 exit status
make: *** [Serial-LowPower-Demo_3.axf] Error 1

It 'a known issue? There's something I have to change/add in the project options?

24 Feb 2017

I also tried with MBED CLI and have the same problem!!

work with mbed-os-example-blinky, NOT WORK WITH mbed_blinky

root@antoDeb8:/home/anto/Projects/mbed/mbed_blinky# mbed compile -t GCC_ARM
[mbed] Auto-installing missing Python modules...
Building project mbed_blinky (EFM32GG_STK3700, GCC_ARM)
Scan: .
Scan: mbed
Scan: env
Compile [100.0%]: main.cpp
Link: mbed_blinky
/home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/libmbed.a(error.o): In function `error':
error.c:(.text.error+0x16): undefined reference to `__wrap_exit'
/home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m/libc.a(lib_a-mprec.o): In function `_Balloc':
mprec.c:(.text._Balloc+0x24): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x40): undefined reference to `__wrap__calloc_r'
collect2: error: ld returned 1 exit status
[ERROR] /home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m/crt0.o: In function `_start':
(.text+0x4e): undefined reference to `__wrap_exit'
./mbed/f9eeca106725/TARGET_EFM32GG_STK3700/TOOLCHAIN_GCC_ARM/libmbed.a(error.o): In function `error':
error.c:(.text.error+0x16): undefined reference to `__wrap_exit'
/home/anto/Projects/mbed/gcc-arm-none-eabi-5_4-2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-m/libc.a(lib_a-mprec.o): In function `_Balloc':
mprec.c:(.text._Balloc+0x24): undefined reference to `__wrap__calloc_r'
mprec.c:(.text._Balloc+0x40): undefined reference to `__wrap__calloc_r'
collect2: error: ld returned 1 exit status

[mbed] ERROR: "python" returned error code 1.
[mbed] ERROR: Command "python -u /home/anto/Projects/mbed/mbed_blinky/.temp/tools/make.py -t GCC_ARM -m EFM32GG_STK3700 --source . --build ./BUILD/EFM32GG_STK3700/GCC_ARM" in "/home/anto/Projects/mbed/mbed_blinky"
---
08 Mar 2017

I had the same problem using the mbed-cli and got it working by updating the "mbed" dependency.

13 May 2017

What commands did you use to "update the 'mbed' dependency"?