linker error: multiple definition of `putchar

akorud wrote on Thursday, June 04, 2009:

Hi,
I’m trying to compile FreeRTOS 5.3.0 STM32 Primer example (unmodified). RIDE and development environment is fresh and clear:
Ride7 7.20.09.0139
Rkit-ARM 1.20.09.0153

Everything compile fine, except linking:
Running: LD
"C:\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker “C:\work\FreeRTOS\Demo\CORTEX_STM32F103_Primer_GCC\RTOSDemo.elf.ld” -u _start -Wl,-static -Wl,–gc-sections -nostartfiles -Wl,-Map -Xlinker “C:\work\FreeRTOS\Demo\CORTEX_STM32F103_Primer_GCC\RTOSDemo.map”  
C:\Raisonance\Ride\Lib\ARM\STM32x_io_putchar_thumb.a(STM32F10X_IO_putchar.o): In function `putchar’: 
STM32F10X_IO_putchar.c:(.text.putchar+0x0): multiple definition of `putchar’ 
c:/raisonance/ride/arm-gcc/bin/…/lib/gcc/arm-none-eabi/4.3.2/…/…/…/…/arm-none-eabi/lib/thumb2\libc.a(lib_a-putchar.o):putchar.c:(.text+0x0): first defined here 
collect2: ld returned 1 exit status

The I have no idea how to prevent linker from linking libc putchar, any ideas?

Regards,
Andriy

rtel wrote on Thursday, June 04, 2009:

The error is telling you where to two definitions are.  One is in the libc library, and the other in STM32F10X_IO_putchar.c - so you need to either remove the .c file from the build or not use the library.  I suspect this is a compiler or link option setting problem and must be caused by a different Ride version to the one used to create the demo.

Regards.

akorud wrote on Thursday, June 04, 2009:

Thanks, it’s exactly I supposed.
The problem that I have no idea how to avoid linking libc - it’s linked automatically. And worse, I want libc - there are many useful function there. And the goal is to use both - putchar from STM32F10X_IO_putchar.c and libc for the rest.
Any ideas? Maybe I’m wrong somewhere?

regards,
Andriy