Our target is Cortex-M4. We are coding in C++ and compiling with armclang.
We use retarget.c to retarget I/O to a special hardware port (we provide puts() etc).
retarget.c contains:
struct __FILE { int handle;}; FILE __stdout; FILE __stdin;
to avoid linking in stdio.o from the C Library.
This all works fine. However, I want to disable exception handling so I added compiler option:-fno-exceptions
and now I get a linker error:
Error: L6200E: Symbol __stdout multiply defined (by stdio_streams.o and retarget.o).
I've disabled all use of assert (though the error occurs with both release and debug builds). There is no use of cout or printf.Any ideas why we are seeing this error only with -fno-exceptions active?
Hi David,
I believe you need to define __FILE_INCOMPLETE
https://developer.arm.com/documentation/100073/0619/The-Arm-C-and-C---Libraries/Redefining-low-level-library-functions-to-enable-direct-use-of-high-level-library-functions-in-the-C-library
Regards, Ronan
Hi Ronan
I already specify -D__FILE_INCOMPLETE to the compiler. The strange thing is that the error only occurs with -fno-exceptions.Regards,
David
Hi DavidThe best way to investigate issues like this is to link with --verbose and then to analyze the references & definitions for the reported symbol.I've not been able to construct an example that reproduces the same error that you see, but we suspect you've not defined __stderr, so stdio_streams.o is being linked-in to provide a definition. But stdio_streams.o also defines __stdin & __stdout, resulting in a clash with those symbols already defined in retarget.o.Hope this helps you to resolve the issue,Stephen
Thankyou Stephen. Defining __stderr fixed the problem.