cancel
Showing results for 
Search instead for 
Did you mean: 

Why STM32CubeIDE linker files discard libc.a libg.a and libgcc.a?

CMars.1
Associate II

Just out of curiosity. Why STM32CubeIDE linker files discard libc.a libg.a and libgcc.a?

At the end of the linker file we usually find:

  /* Remove information from the compiler libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
  }

Maybe I didn't get something right but, shouldn't the libc.a include all the C standard library code, so it should be needed to compile a C application?

Regards,

2 REPLIES 2
BPetk.1
Associate II

Hi,

Did you by any chance manage to find an answer to this question?

I tried using libc_nano.a instead of libc.a and I wasn't able to compile my code until I changed the linker file to discard libc_nano.a as well.

The linker complained of multiple definitions of almost all functions inside libc.a and I don't know why.

However, in CubeMX there seems to be no option to use libc_nano.a which would generate the correct LD file and this isn't exactly an obvious thing to look for.

Regards

SBrün.1
Associate

Naming the library in the DISCARD section includes the whole library. You can change it to

libc.a:* ( * )

avoid this.