Skip to main content
Joerg Wagner
Senior III
May 5, 2019
Question

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

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.

This topic has been closed for replies.

5 replies

Markus GIRDLAND
ST Employee
May 6, 2019

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
May 8, 2019

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.

Markus GIRDLAND
ST Employee
May 8, 2019

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

And when you do so everything works fine again?

Joerg Wagner
Senior III
May 6, 2019

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.