Unable to add certain components in custom library

Ajaykrishna123
Posts: 1
Joined: Sun May 03, 2020 3:30 am

Unable to add certain components in custom library

Postby Ajaykrishna123 » Sun May 03, 2020 3:36 am

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.

wevets
Posts: 112
Joined: Sat Mar 09, 2019 2:56 am

Re: Unable to add certain components in custom library

Postby wevets » Mon May 04, 2020 6:42 am

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:
  1. idf_component_register(   SRCS "blotto.c"
  2.                     INCLUDE_DIRS "."
  3.                     REQUIRES "nvs_flash" )
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.

espnewbie
Posts: 6
Joined: Thu Aug 06, 2020 2:49 pm

Re: Unable to add certain components in custom library

Postby espnewbie » Tue Mar 02, 2021 3:10 pm

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.

Code: Select all

idf_component_register(SRCS "adc1_example_main.c"
                    INCLUDE_DIRS "."
                    REQUIRES "esp_adc_cal")
Do I miss anything aside from this?

Who is online

Users browsing this forum: asargent, Google [Bot] and 69 guests