Skip to main content
Raymond Buck
Senior
March 19, 2017
Solved

How to add fsdata.c file to project?

  • March 19, 2017
  • 5 replies
  • 6371 views
Posted on March 19, 2017 at 21:42

I have the STM32F407 Discovery board running with LWIP. I am able to ping the board and get replies.

I now want to get a Web Server running on the board. I used CubeMX and Enabled LWIP_HTTPD on the HTTPD configuration tab. I generated the code and imported it into System Workbench.

I created a simple web page with two html files. I then used makefsdata.exe to create the fsdata.c file and added it to the project.

When I compile the project, I get these errors:

Middlewares/Third_Party/LwIP/src/apps/httpd/fsdata.o:(.rodata+0x0): multiple definition of `file__related_html'

Middlewares/Third_Party/LwIP/src/apps/httpd/fs.o:(.rodata+0x0): first defined here

Middlewares/Third_Party/LwIP/src/apps/httpd/fsdata.o:(.rodata+0x14): multiple definition of `file__programming_html'

Middlewares/Third_Party/LwIP/src/apps/httpd/fs.o:C:\STMNew\Eth-Test\Release/../Middlewares/Third_Party/LwIP/src/apps/httpd/fs.c:85: first defined here

I looked in fs.c and do not see my two html files (related.html, programming.html) mentioned  anywhere so I don't understand why the linker thinks there are multiple definitions.

I believe the errors may be related to this code in fs.c:

#if HTTPD_USE_CUSTOM_FSDATA

#include 'fsdata_custom.c'

#else /* HTTPD_USE_CUSTOM_FSDATA */

#include 'fsdata.c'

#endif /* HTTPD_USE_CUSTOM_FSDATA */

Is there a document available that has instructions on how to setup a Web Server using System Workbench? I've searched but haven't really turned up any useful information. I do find some

stuff for LWIP v1.0.1. But I assume System Workbench is using some variation of v2.x.x

    This topic has been closed for replies.
    Best answer by Fabien DESSEREE
    Posted on March 29, 2017 at 17:12

    Hello,

    as you can see in fs.c file, fsdata.c is directly included at the begining of fs.c, so it means that the compiler physically copy the content of fsdata.c file at the place of #include 'fsdata.c' directive and then compile the whole file.

    So to fix multiple definition you need to exclude fsdata.c from your project build (for exemple if you use eclipse, right click on the file, select Properties and check 'Exclude from build')

    Hope it will help you

    5 replies

    andrea formentin
    Visitor II
    March 21, 2017
    Posted on March 21, 2017 at 16:12

    same issue here. I'm not able to run webserver example on ac6 ide because 'multiple definition error' on fs.c

    Fabien DESSEREE
    Fabien DESSEREEBest answer
    Visitor II
    March 29, 2017
    Posted on March 29, 2017 at 17:12

    Hello,

    as you can see in fs.c file, fsdata.c is directly included at the begining of fs.c, so it means that the compiler physically copy the content of fsdata.c file at the place of #include 'fsdata.c' directive and then compile the whole file.

    So to fix multiple definition you need to exclude fsdata.c from your project build (for exemple if you use eclipse, right click on the file, select Properties and check 'Exclude from build')

    Hope it will help you

    Raymond Buck
    Senior
    March 29, 2017
    Posted on March 29, 2017 at 21:28

    Yes, someone else pointed that out. Once I excluded the fsdata.c file from the project build, I was able to successfully compile the code. Everything is working fine now. I have a temporary webpage being displayed. I haven't gotten around to setting up a page so I can have callback functions to test yet. Hopefully I will get to that in the next week or so.

    Mark Shoe
    Associate III
    October 19, 2017
    Posted on October 19, 2017 at 09:35

    Where should the fsdata_custom.c be located? It works fine in the httpd directory however it is deleted by CubeMX with a new project generation. Logical should be be Src together with the other custom files. This gives an error: fc.c cannot find fsdata_custom. My Src is included in the Source locations. Or should i place is somewhere out of reach so 'exclude from build' is not needed?

    bully
    Senior
    July 28, 2019

    Hello,

    I have same problem... I must manually recopy file on each code regeneration ???

    Any solution ?

    Regards,

    Bully.

    Raymond Buck
    Senior
    March 30, 2020

    Yes, place fsdata_custom.c in Middlewares/Third_Party/LwIP/src/apps/http. The latest version of CubeMX for some stupid reason wants to see the file in that directory. I don't know what http has to do with httpd but maybe the programmers at ST had a reason to think they were related. The older versions of CubeMX had it correctly placed in the httpd directory. Each regeneration of the code will remove the file so save a copy so you can copy it back to the http directory.

    Broekman
    Visitor II
    June 7, 2021

    Old thread, but for this specific reason I have just added the ../Src directory to the include directories, allowing me to place fsdata_custom.c in the normal Src directory. Not the "neatest" solution but as long as you don't misuse it for anything else, it's a clean enough solution for now and you can just regenerate.