Managing library includes in esp-idf components

ujurmsde
Posts: 73
Joined: Tue Jan 19, 2021 6:37 am

Managing library includes in esp-idf components

Postby ujurmsde » Wed Dec 10, 2025 2:33 am

I have a library with many files that needs to be include. There are folders inside a main folder.

Now, I know that with custom components one can do this but not sure how to do this when I have multiple files spread across in many folders.

Is there some examples to show this scenario?

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

Re: Managing library includes in esp-idf components

Postby MicroController » Wed Dec 10, 2025 9:21 am

https://docs.espressif.com/projects/esp ... ists-files

You create a directory for your component/library with all the sources and header files in it. In that component directory you also create a component CMakeLists.txt file with a call to idf_component_register(...) in it.
In the arguments to idf_component_register() you specify the source files to be compiled (SRCS), any/all include directories where component-internal header files are located (PRIV_INCLUDE_DIRS), and any/all directories where the header files reside which other components should be able to include/use (INCLUDE_DIRS).

Who is online

Users browsing this forum: Bing [Bot], Bytespider, ChatGPT-User, PerplexityBot, Qwantbot and 5 guests