5 years, 8 months ago.

Export to a CDT Project for Eclipse GCC ARM

Hello all,

I already have some experience with the mbed online compiler. Now I wanted to collect offline on Eclipse with the GNU ARM tools experiences. But that just does not work. First, I created a new project for the nucleo-32F303k8 board in the mbed environment. To keep it simple, just with the blinky example. This then compiled and loaded onto the board. That worked as expected. Next, I exported the project for GNU ARM Eclipse and opened it as a project in Eclipse. Eclipse has recognized it as a CDT project and opened it correctly.

When translating, the compiler also ran smoothly, but the linker provided some error messages:

…In function `__sflush_r':
fflush.c:(.text.__sflush_r+0x90): undefined reference to `__wrap__free_r'
…In function `__sfmoreglue':
findfp.c:(.text.__sfmoreglue+0xe): undefined reference to `__wrap__malloc_r'
…In function `__smakebuf_r':
makebuf.c:(.text.__smakebuf_r+0x2a): undefined reference to `__wrap__malloc_r'
…In function `free':
malloc.c:(.text.free+0x6): undefined reference to `__wrap__free_r'
…In function `__swsetup_r':
wsetup.c:(.text.__swsetup_r+0x62): undefined reference to `__wrap__free_r'
… In function `__ssputs_r':
nano-vfprintf.c:(.text.__ssputs_r+0x3e): undefined reference to `__wrap__malloc_r'
nano-vfprintf.c:(.text.__ssputs_r+0xa0): undefined reference to `__wrap__realloc_r'
nano-vfprintf.c:(.text.__ssputs_r+0xae): undefined reference to `__wrap__free_r'
… In function `_svfiprintf_r':
nano-vfprintf.c:(.text._svfprintf_r+0x1a): undefined reference to `__wrap__malloc_r'

Now I find only bug fixes, which propose removing several -Wl options in the makefile. Now a managed CDT project does not have a makefile. Even in the project settings, I can not find a point where I could change the missing or unnecessary settings. The description of the mbed export function claims only: The GNU Arm Eclipse exporter generates ready to run managed CDT projects.

What's wrong?

1 Answer

5 years, 8 months ago.

Hi Hermi,

Are you using an mbed 2 program? If so, the exporting docs warn that there may be some linker flag errors that may need to be fixed.

To find the flags:

  • Right-click on the project and click on Properties
  • In the left hand side, click on C/C++ Build and navigate to the Settings tab underneath
  • Under Tool Settings, find Cross ARM C++ Linker and click on the Miscllaneous tab underneath
  • There should be a box labeled Linker flags (--wrap=main....)
  • Remove the malloc, free, realloc, calloc flags

/media/uploads/karencyen/flag-picture.png

I was able to compile the program after removing the flags. If you want to get some more insight, here are a few github issues that may be helpful:

https://github.com/ARMmbed/mbed-os/issues/4624

https://github.com/ARMmbed/mbed-os/issues/3673

Let us know if you have any more questions!

-Karen, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

Accepted Answer