I am trying to add my own library as a component in the components directory. I am unable to add certain built in esp if components that my library uses. Here are the include statements in my .c file.
#include "esp_log.h"
#include "driver/gpio.h"
#include "driver/adc.h"
#include "esp_adc_cal.h"
The first three include statements work without any error. However build fails as the esp_adc_cal.h file is found.
I get the following error:
../components/ec_sensor/ec_sensor.c:11:10: fatal error: esp_adc_cal.h: No such file or directory
#include "esp_adc_cal.h"
^~~~~~~~~~~~~~~
compilation terminated.
I get the same error for nvs.h. The header file is not found during the build process.
Any help would be appreciated, I am new to the ESP 32.
Unable to add certain components in custom library
-
- Posts: 1
- Joined: Sun May 03, 2020 3:30 am
Re: Unable to add certain components in custom library
I just had this problem and got help on the board from ESP_Angus and Junior.
In the CMakeLists.txt file for the component for which esp_adc_cal.h is not found, add
REQUIRES "esp_adc_cal"
as the last statement in the idf_components_register statement.
In the CMakeLists.txt file for the component for which nvs.h is not found, add
REQUIRES "nvs_flash"
One of my CMakeList.txt files for a component named "blotto" looks like this:
It seems that CMake only searches the most commonly used directories in the IDF by default for speed. If you need to include those less commonly used included files, CMake has to be told where to look for them.
The documentation is not very clear on this point, providing no examples that are on point and lots of information that is clear only if previously understood.
In the CMakeLists.txt file for the component for which esp_adc_cal.h is not found, add
REQUIRES "esp_adc_cal"
as the last statement in the idf_components_register statement.
In the CMakeLists.txt file for the component for which nvs.h is not found, add
REQUIRES "nvs_flash"
One of my CMakeList.txt files for a component named "blotto" looks like this:
- idf_component_register( SRCS "blotto.c"
- INCLUDE_DIRS "."
- REQUIRES "nvs_flash" )
The documentation is not very clear on this point, providing no examples that are on point and lots of information that is clear only if previously understood.
Re: Unable to add certain components in custom library
It doesn't work for me. Currently, I am working with the ADC example but I always got the same error.
this is the code I have on the CMakeLists.txt of the main folder.
Do I miss anything aside from this?
this is the code I have on the CMakeLists.txt of the main folder.
Code: Select all
idf_component_register(SRCS "adc1_example_main.c"
INCLUDE_DIRS "."
REQUIRES "esp_adc_cal")
Who is online
Users browsing this forum: No registered users and 92 guests