PlatformIO Community

Using ESP-IDF and try to compile http server example


#1

Hi,
i’m new in Plattform io.
i’m trying to compile the http_server/advanced_tests example from espressif idf samples folder (esp-idf\examples\protocols\http_server).

For this I created 3 files in PlattformIo IDE.

in src:

  • main.c
  • tests.c

and in include

  • tests.h

After that i copied the Content of the files from the sample in the new files.

But when i compile, i get the following Errors:

  • "cannot open source file “esp_http_server.h”
    (this is at the line include <esp_http_server.h>; The File is in the idf components include directory

  • "#include errors detected. Please update your includePath. IntelliSense features for this translation unit (C:\SPB_Data\Documents\PlatformIO\Projects\test\src\main.c) will be provided by the Tag Parser.
    (This error is at the line #include “tests.h”)

What can i do?


#2

Could you provide?

  1. Full link to ESP-IDF example
  2. A test PlatformIO project to reproduce this issue

#3

Comparing the components of the github repository of esp-idf


and the contents of
\.platformio\packages\framework-espidf\components
I can see that there is no http_server library in the esp-idf version of the current pio espressif platform (my espressif 32 platform version is 1.6.0).
You could maybe try to download the library by itself and add it to your project.


#4

I am in the same situation here.


#5

Is there a solution for this? I’m running into the same issue trying to include the mqtt component from esp-idf.


#6

For the mqtt-library the same is true as I have stated earlier in this thread. While there are mqtt and http-server components in the newer esp-idf releases those releases have not yet been incorporated into the PIO platform. If you want to use either of them you will have to add them to your components manually or wait until they get part of the offical PIO platform.


#7

You should only take the Espressif example code for the version of ESP-IDF that PIO has, currently 3.1.2 (see here). Does it work with their example code from the 3.1 tree? https://github.com/espressif/esp-idf/tree/release/v3.1


#8

Hey thanks @Thomseeen, thanks. I actually found the package on the platformio library finder and ended up going that route. However for future reference, whats recommended for manually including external libs?

I tried a few ways of manually including it:

  • copied the esp-idf/components/mqtt folder to ~/.platformio/platforms/esp-idf/components folder

  • copied the esp-idf/components/mqtt folder to the lib/ folder in my project workspace

Neither of these things worked and platformio still couldn’t find the header file. Is there something I’m missing? I’m using PlatformIO, version 3.6.3 in VSCode if it matters.


#9

The esp-idf/components/mqtt directory at github only links to another github with the real library.


I don’t know how you copied the mqtt folder but your way might have missed the actual library. If you download it there directly you should be able to include it in your projects lib-folder. For PIO to find all the headers it might be the easiest way to then copy all source and header files of the library in the top-most folder (I found that otherwise PIO won’t find some files). The last step you will then need to do is adapt the CMake configs into “normal” header files to include in the library source files where needed.
i.e. merge https://github.com/espressif/esp-idf/blob/master/components/mqtt/Kconfig into something like your sdkconfig.h and include it into the libraries header files.