Page 1 of 1

Can't reference IDF headers from /components

Posted: Thu Nov 21, 2019 1:45 am
by growver
Hi,
If I have code in the 'components' section of a project, how do I access esp-idf headers? Everything builds fine until I include say nvs_flash.h
Then I get a file not found error when I build. Is there a cmakelists.txt configuration that exposes esp-idf to source in the /components folder? The same #include <nvs_flash.h> works fine in /main of course.

Re: Can't reference IDF headers from /components

Posted: Thu Nov 21, 2019 5:28 am
by ESP_Angus
Hi,

Are you using the CMake build system (this is the default in IDF v4.0 and newer)?

CMake components have to declare which other IDF components they depend on. We do this to optimize the build process. So your new component needs to declare that it depends on the nvs_flash component.

For master branch, you can read about the process here:
https://docs.espressif.com/projects/esp ... quirements

If you're using ESP-IDF v3.x with CMake, the process is slightly different.

Re: Can't reference IDF headers from /components

Posted: Fri Nov 22, 2019 2:09 am
by growver
Thanks Angus, very helpful!

I now follow that the /components in my project requires explicit access to each esp-idf component.

I'm using IDF v4.0, so for anyone reading this, there were two things:

1) Adding necessary IDF components with a REQUIRES addition to cmakelists.txt
  1. idf_component_register(SRCS "app_prov.c" "app_prov_handlers.c"
  2.                        REQUIRES nvs_flash bt wifi_provisioning)
2) I also forget to enable Bluetooth in menuconfig.

Both changes were needed for successful compilation and linking.