cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeIDE + LwIP : lwip/opt.h no such file

Joerg Wagner
Senior III

I built a tiny project from scratch with LwIP (without FreeRTOS).

CubeMX generates a project without any errors which I can compile and run.

But when I modify my source code in main.c every compile stops with:

../Inc/lwip.h:28:10: fatal error: lwip/opt.h: No such file or directory

In Tool Settings->MCU GCC Compiler->Includes are no entries in the list.

I added at least:

../Middlewares/Third_Party/LwIP/src/include

../Middlewares/Third_Party/LwIP/system

../Middlewares/Third_Party/LwIP/src/include/lwip

../Middlewares/Third_Party/LwIP/src/include/lwip/apps

../Middlewares/Third_Party/LwIP/src/include/lwip/priv

../Middlewares/Third_Party/LwIP/src/include/lwip/prot

Same problem.

But when I make a change in CubeMX, save it and new code is generated

the project can be compiled.

How can I fix this to be able to compile a project with LwIP in STMCubeIDE ?

Thank you.

5 REPLIES 5
Markus GIRDLAND
ST Employee

I tried creating a LwIP project but I can't reproduce your issue. I can make changes to my main.c file just fine and it still works.

If you can specify a way for me to reproduce this, step-by-step then I might be able to be more helpful.

Joerg Wagner
Senior III

I created now a second project and copied all the include paths into the first one.

Now it works, I can compile after changing the code.

Like I said, the include paths list was empty.

Thank you.

After this fix I changed my code concerning SPI only.

But sometimes this occurs:

.../Debug/../Src/ethernetif.c:563: undefined reference to `etharp_output'

Src/lwip.o: In function `MX_LWIP_Init':

.../Debug/../Src/lwip.c:72: undefined reference to `lwip_init'

.../Debug/../Src/lwip.c:80: undefined reference to `netif_add'

.../Debug/../Src/lwip.c:83: undefined reference to `netif_set_default'

.../Debug/../Src/lwip.c:88: undefined reference to `netif_set_up'

.../Debug/../Src/lwip.c:93: undefined reference to `netif_set_down'

.../Debug/../Src/lwip.c:99: undefined reference to `ethernet_input'

collect2: error: ld returned 1 exit status

make: *** [makefile:41: pccv4_767.elf] Error 1

( The ... represents the full correct path)

I do not use network functions this time (comes later), LwIP is just enabled in the project.

The only way I know to get rid of this errors is to change the .ioc file with CubeMX and regenerate the project.

This can not be the way to work serious.

So this error appears and you can "work around" that problem by regenerating the project?

And when you do so everything works fine again?

Yes. Regenerating is the magic.

But lwip compiling errors do not occur after each compile.

It happens sometimes.

Edited: It happens most of the time when I start STM32CubeIDE.

I came from SW4STM32 and never had a similar problem.