Can't reference IDF headers from /components

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Can't reference IDF headers from /components

Postby growver » Thu Nov 21, 2019 1:45 am

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.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Can't reference IDF headers from /components

Postby ESP_Angus » Thu Nov 21, 2019 5:28 am

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.

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Re: Can't reference IDF headers from /components

Postby growver » Fri Nov 22, 2019 2:09 am

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.

Who is online

Users browsing this forum: No registered users and 88 guests