Problems with integrating header files

Hello,
I would like to use with Visual Studio Code and Platformio for example this program (sketch):

TFT_eSPI_OpenWeather

With the platformio.ini I downloaded the different libraries with this code:

lib_deps=
https://github.com/Bodmer/OpenWeather
https://github.com/Bodmer/TFT_eSPI
https://github.com/Bodmer/JSON_Decoder
https://github.com/JChristensen/Timezone
https://github.com/PaulStoffregen/Time
https://github.com/Bodmer/JPEGDecoder

I noted that in my main.cpp (TFT_eSPI_OpenWeather.ino) the compiler / Linker doesn’t find different headerfiles like „All Settings.h“ or „GfxUi.h“. I get this error:

„include errors detected. Please update your includePath."

When I open the Microsoft c/c++ extension and add a new includepath like „d:/Prog/ESP32/TFT_eSPI_OpenWeather/.pio/libdeps/esp32dev/** " it works, but when I close the Visual Studio Code and reopen the programm I have to add again the new includepath.* I red that with „“**“ is search the subdirectory, too.

In addition when I build the main.cpp I get the error

“Compiling .pio\build\esp32dev\libfc4\JPEGDecoder\JPEGDecoder.cpp.o"
In file included from .pio\libdeps\esp32dev\JPEGDecoder\src\JPEGDecoder.cpp:39:0:*
.pio\libdeps\esp32dev\JPEGDecoder\src\JPEGDecoder.h:62:36: fatal error: SD.h: No such file or directory”.

When I open the file JPEGDecoder.h and search in the row 62 the definition (F12) I find the SD.h file in the path C:\Users\abc.platformio\packages\framework-arduinoespressif32\libraries\SD\src\SD.h.*

What I’m doing wrong?
Can someone help me?

Thank you very much for your help.

Hello,
Nobody an idea what I’m doing wrong or know what can I do to resolve the problem?
Thank you for your support.

Unable to reproduce problem.If I create a new blank ESP32 Dev Module project, use your lib_deps expression and copy all files (except data) from the example into the src/ directory of the project, plus the data/ directory in the root of the project, it builds no problems.

Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Building .pio\build\esp32dev\firmware.bin
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  13.2% (used 43312 bytes from 327680 bytes)
Flash: [========  ]  76.9% (used 1007542 bytes from 1310720 bytes)
esptool.py v3.0
============================ [SUCCESS] Took 18.43 seconds ============================
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps=
    https://github.com/Bodmer/OpenWeather
    https://github.com/Bodmer/TFT_eSPI
    https://github.com/Bodmer/JSON_Decoder
    https://github.com/Bodmer/JPEGDecoder
    https://github.com/JChristensen/Timezone

Also IntelliSense in the source is there (no missing header files or anything) but limited as long as the
file extension is .cpp, as the popup tells you

Are you sure your project is setup exactly the way I have it?

@maxgerhardt:
Thank you for your detailed answer and your willingness to help!
Compared with your instructions, I made some big mistakes:
-Have NOT copied all files (except data) in the scr / direcotory of the project.
-Have NOT copied the data / direcotory in the root of the project.

Was of the opinion that the compiler / linker is looking for the header files in the lipdeps folder.

Now I have to look how I change the MoonPhase.ino file into a correct file format to integrate it correctly so that the “main” program can access to the correct library.

I have learned something important again and have come a step further in my programming.

Every beginning is difficult, but with your great willingness to help, a lot is easier. Thanks again.
Sorry for my bad english.

Glad to be of help.

Also remember, the data/ folder isn’t automatically converted to a SPIFFS filesystem image and uploaded to the ESP32, you have to execute the Upload Filesystem Image project task for it (docs).

grafik

As an exercise you can also convert all .ino files to .cpp files so that you get full IntelliSense :wink:

Edit: You can also see GitHub - maxgerhardt/pio-tft-weatherstation: https://github.com/Bodmer/OpenWeather/tree/master/examples/TFT_eSPI_OpenWeather as PIO compilable project for reference.

Thank you for the important information.

Great work! Thank you. Certainly helpful for others too.

Do I have to create a header file “MoonPhase.h” and also include it in the main program so that, for example, the moon_phase function is found in the correct file?

Thank you again for your @maxgerhardt great willingness to help and your detailed answer!!!
Great!!!

You can create that file, and then include it in the main.cpp and moonphase.cpp code, but the way I did in the repo (it’s already converted to proper C++) I just added the function prototype in main.cpp. This is enough so that the function will be found during linking.

@maxgerhardt Thank you very much for your helpfulness and your easily understandable information!