AnsweredAssumed Answered

Another retarget.c issue

Question asked by campbell.jamie on May 13, 2015
Latest reply on May 13, 2015 by campbell.jamie

Hi All,

I've been working my way through all the retarget.c threads on here and today, trying to resolve the old

Symbol __stdout multiply defined (by stdio_streams.o and retarget.o)
Symbol __stdin multiply defined (by stdio_streams.o and retarget.o)

linker errors.

I have had a retarget.c file in my project for the past 6 months, and everything has been fine. These errors have occurred since I changed the char-based strings in my application to wchar-based strings, and replaced strcpy with wcscpy etc.

Since this change I get the multiply-defined symbols, and using MicroLib is obviously not an option due to lack of wchar support.

If I remove the definitions from my retarget.c, I get the following error:

__use_no_semihosting_swi was requested, but _sys_open was referenced

and if I remove the #pragma import(__use_no_semihosting_swi) then I see the classic BKPT in _sys_open before main.

I have no idea what is causing _sys_open to be called because all printf's are removed, and there are no calls to fopen() or freopen().

I'm using Keil uVision for Cortex M3 (STM32F2XX), and at the moment I'm not even convinced which issue I should try to fix. As my retargetting has been working up until now I thought getting rid of the multiply defined symbol warnings would be the path of least resistance.

I just CAN NOT figure out where the stdio_streams.o definition is coming from, or even where an object file name of stdio_streams.o would come from. I'm presuming it is a component of a prebuilt lib somewhere, but then again I'm not explicitly linking any libs...

Does anyone have any tips to help track down this extra definition?