Struggling to figure out how to include IDF components

mikeselectricstuff
Posts: 1
Joined: Fri Jun 19, 2026 5:41 pm

Struggling to figure out how to include IDF components

Postby mikeselectricstuff » Sat Jun 20, 2026 5:27 pm

I'm new to ESP, and have been tinkering with some examples for the Waveshare 3.4" LCD board. using IDF 5.5.4 with VScode.
There are two examples, which do pretty much all I need - 05_sdmmc and 07_Displaycolorbar.

I have both of these working fine on their own, but am having no luck combining them into one project, specifically figuring out how to enable components & have it recognise #include headers.

I'm sure I'm missing something fundamental but have spent ages looking at docs and numerous tutorial vids and am still none the wiser!

A simple example - in the LCD demo, I use

Code: Select all

#include "esp_cache.h"
so I can update the cache to display correctly, however if I include this in the sdmmc project main C source, I get a "file not found" error on this include file when building.

I've looked through all the files in both projects and can't for the life of me figure out how teh build system gets told which components need to be included, or where to find the include files. I thought this was to do with the sdkconfig, but as far as I can see this is about configuring components rather than specifying which components are included

One difference I see is that the LCD has a "managed_components" folder but sdmmc does not.

What am I missing?

MicroController
Posts: 2669
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Struggling to figure out how to include IDF components

Postby MicroController » Sun Jun 21, 2026 2:06 pm

https://docs.espressif.com/projects/esp ... cmakelists

In your project, you normally have a directory "main", in which the CMakeLists.txt file for the "main" component of your application lives. In this file, you declare which components your application ("main") depends on via the REQUIRES argument.
Some components (FreeRTOS,...) are included in every build automatically, but others must be explicitly named. Check the respective files of the examples and add the needed components as REQUIRES to your "main" CMakeLists.txt. After editing the CMakeLists.txt you may have to run "idf.py reconfigure" on your project to update the include paths, if it doesn't run automatically.

Some components don't come with the IDF but need to be downloaded separately, commonly from the ESP Component Registry, which can be automated by using the IDF Component Manager (via the idf_component.yml file.)

Who is online

Users browsing this forum: coccocbot, GPTBot and 2 guests