cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix "multiple definition of `errno"'?

DK.7
Senior

I try to create a new project, nothing is written in main.c! It is a first check after setting up 'LWIP', 'SDIO' and Freertos in the GUI and got this mistake!

multiple definition of `errno'; ./Middlewares/Third_Party/LwIP/system/OS/sys_arch.o:/home/denis/STM32CubeIDE/workspace_1.9.0/FreeRtos_SDIO_Web/Debug/../Middlewares/Third_Party/LwIP/system/OS/sys_arch.c:45: first defined here

STM32CubeIDE Version: 1.9.0

PS - This error not appear then I was on STM32CubeIDE Version: 1.8.0

1 ACCEPTED SOLUTION

Accepted Solutions
22 REPLIES 22

>>How to fix "multiple definition of `errno"'?

Remove all but one? Make some weak?

Make sure multiple instances of the same object aren't pulled in

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

The file "sys_arch.o" is not readable.

And if I will comment three lines in the file sys_arch.c is it will correct?

I'm asking because according to the error /Middlewares/Third_Party/LwIP/system/OS/sys_arch.c:45: first defined here0693W00000Lw2S7QAJ.png0693W00000Lw2RnQAJ.png

Thanks for the link! But, in my case, I have nothing in main.c and there is nothing in headers files and so on. It is a first check after setting up in GUI what I do wrong or how it is fix?

Pavel A.
Evangelist III

If you're using the ST toolchain, errno is defined by its C library (newlib).

So just #include <errno.h> ; remove all other definitions of errno,

From the thread I linked to:

> ... use -fcommon to compile ...

JW

Is it correct?0693W00000Lw2noQAB.png

Could you please make screen? Because I don't understand what you are mean...

Or remove the command line define LWIP_PROVIDE_ERRNO, or have it called out as "extern"

Evidently the devs have previously had just this issue.

Pretty sure using "extern" would have all secondary references fold into one.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..