Arm Mbed OS support forum

Problem exporting an example to make-gcc-arm

I am testing an example of a simple blinky, using the CORE-F103RB, I exported the example from the online compiler to use with make-gcc-arm but it does not work when compiling, it generates a strange error with the Makefile, I use mbed 2.

/usr/bin/…/lib/gcc/arm-none-eabi/7.3.1/…/…/…/…/arm-none-eabi/lib/thumb/v7-m/crt0.o: In function _start':** **(.text+0x4e): undefined reference to __wrap_exit’
…/mbed/TARGET_NUCLEO_F103RB/TOOLCHAIN_GCC_ARM/board.o: In function mbed_error_vfprintf':** **board.c:(.text.mbed_error_vfprintf+0x12): undefined reference to __wrap_vsprintf’
…/mbed/TARGET_NUCLEO_F103RB/TOOLCHAIN_GCC_ARM/libmbed.a(error.o): In function error':** **error.c:(.text.error+0x16): undefined reference to __wrap_exit’
collect2: error: ld returned 1 exit status
/home/ignacio/Documents/Project/Code/mbed_blinky/Makefile:382: recipe for target ‘mbed_blinky.elf’ failed
make[1]: *** [mbed_blinky.elf] Error 1
Makefile:25: recipe for target ‘all’ failed
make: *** [all] Error 2

I remember in the past I did the same using a TEENSY3.1 and never had a problem doing the same, but now I try to do the same with a teensy and it doesn’t work either.

Regards.
Francisco

Hello Francisco,

This doesn’t seem to be an export problem. Maybe this old thread could help.

Dear Zoltan Hudak, thank you very much for the answer, I thought it was a problem to update the mbed library to the latest version among other things, it was not like that, I currently receive the following error:
make: Warning: File ‘Makefile’ has modification time 14093 s in the future
make[1]: Warning: File ‘/home/ignacio/Documents/Project/Code/STM32F103C8T6_Hello/Makefile’ has modification time 14093 s in the future
Compile: main.cpp
link: STM32F103C8T6_Hello.elf
…/mbed/TARGET_NUCLEO_F103RB/TOOLCHAIN_GCC_ARM/mbed_board.o: In function mbed_error_vfprintf':** **/home/jenkins/mbed_jenkins/workspace/bm_wrap/1728/mbed-os/platform/mbed_board.c:68: undefined reference to __wrap_vsnprintf’
…/mbed/TARGET_NUCLEO_F103RB/TOOLCHAIN_GCC_ARM/serial_api.o: In function debug':** **/home/jenkins/mbed_jenkins/workspace/bm_wrap/1728/mbed-os/BUILD/mbed/platform/mbed_debug.h:45: undefined reference to __wrap_vfprintf’
…/mbed/TARGET_NUCLEO_F103RB/TOOLCHAIN_GCC_ARM/libmbed.a(Stream.o): In function mbed::Stream::printf(char const*, ...)':** **/home/jenkins/mbed_jenkins/workspace/bm_wrap/1728/mbed-os/platform/Stream.cpp:150: undefined reference to __wrap_vfprintf’
collect2: error: ld returned 1 exit status
/home/ignacio/Documents/Project/Code/STM32F103C8T6_Hello/Makefile:426: recipe for target ‘STM32F103C8T6_Hello.elf’ failed
make[1]: *** [STM32F103C8T6_Hello.elf] Error 1
Makefile:25: recipe for target ‘all’ failed
make: *** [all] Error 2

I hope you can help me

Cheers
Francisco

I’ve seen this linker error before, it has to do with Mbed adding “wrapped versions” of certain functions and the configuring the linker to use them. It looks like the linker flags for the minimal printf library are enabled, but the library isn’t actually being linked. You could try explicitly disabling or enabling minimal printf in your mbed_app.json.

By the way, you might be able to sidestep this and other Mbed exported issues by using mbed-cmake instead. It provides a lot of the same benefits while being far less janky (in my experience).

Warning: File ‘Makefile’ has modification time 14093 s in the future
make[1]: Warning: File ‘/home/ignacio/Documents/Project/Code/STM32F103C8T6_Hello/Makefile’ has modification time 14093 s in the future

The following could help:

  • The ‘Makefile’ seems to be corrupted. Rename it to whatever you like. Create a new ‘Makefile’ and copy&paste the content of the old to the new one.

  • Clean or delete the BUILD directory and rebuild your project.

/home/jenkins/mbed_jenkins/workspace/bm_wrap/1728/mbed-os/platform/mbed_board.c:68: undefined reference to __wrap_vsnprintf’

That’s starange. Which revision of Mbed OS 2 do you use?

I am using version 171: 3a7713b1edbc, I managed to compile the project, in the Makefile I commented on some lines related to the problem:
#ASM_FLAGS + = -DMBED_MINIMAL_PRINTF
#CXX_FLAGS + = -DMBED_MINIMAL_PRINTF
#C_FLAGS + = -DMBED_MINIMAL_PRINTF
I updated MBED OS2 to the latest version but I still had the problem, so I kept the version I mentioned above.

Cheers
Francisco

I managed to compile the project, in the Makefile I commented on some lines related to the problem:
#ASM_FLAGS + = -DMBED_MINIMAL_PRINTF
#CXX_FLAGS + = -DMBED_MINIMAL_PRINTF
#C_FLAGS + = -DMBED_MINIMAL_PRINTF
I don’t have a lot of experience using cmake, but will check it out so I don’t have these issues in the future.
Thanks for your advice and help.

Cheers
Francisco

Oh right, since you’re using mbed 2, make sure to checkout the paleo branch of mbed-cmake. It should be a big improvement!