Page 1 of 1
esp_http_client.h: No such file or directory
Posted: Sun Oct 17, 2021 4:05 pm
by imdaad
I am having a weird issue with ESP-IDF. In my project directory if I call esp_http_client from a main or from a library in the same directory It works. But when I shift the library to somewhere else, this particular library can not be imported. I already got RFID, gpio, and wifi libraries set up in my "lib" directory and works well. Any ideas on how I can solve this problem? No issues in CMakeLists because all the other libraries are working. I have tried many ways but I can't progress any further. The examples of http_clients in IDF works because everything is in the main file and my configuration files are derived from the template project of EPS-IDF. If anyone knows please help me to resolve this issue. Thank you in advance.
Re: esp_http_client.h: No such file or directory
Posted: Mon Oct 18, 2021 1:00 am
by ESP_Sprite
You say 'no issues in the CMakeLists.txt file'... just to make sure, you have esp_http_client in the REQUIRES and/or PRIV_REQUIRES there? If in doubt, can you post the file?
Re: esp_http_client.h: No such file or directory
Posted: Tue Oct 19, 2021 9:05 am
by imdaad
Code: Select all
"includePath": [
"${config:idf.espIdfPath}/components/**",
"${config:idf.espIdfPathWin}/components/**",
"${config:idf.espAdfPath}/components/**",
"${config:idf.espAdfPathWin}/components/**",
"${workspaceFolder}/**"
],
this is my include paths which came by default.
my directory is like this.
project
- .vscode
- libs
- main
- CMakeLists.txt
I already created 3 libraries for other tasks. everything works fine. but I simply can't import http_client library inside the lib folder. I can only realize it in the main folder.
Re: esp_http_client.h: No such file or directory
Posted: Tue Oct 19, 2021 10:52 am
by ESP_Sprite
Sorry, but that doesn't answer any of the questions I asked... Can you specifically post the contents of the CMakeLists.txt in the component where you are trying to use esp_http_client?
Re: esp_http_client.h: No such file or directory
Posted: Tue Oct 19, 2021 12:28 pm
by imdaad
home directory
Code: Select all
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS lib)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
under http directory
Code: Select all
idf_component_register(
SRCS "HTTP.cpp"
INCLUDE_DIRS .
)
Hope this is what you were asking for?
Re: esp_http_client.h: No such file or directory
Posted: Wed Oct 20, 2021 1:23 am
by ESP_Sprite
Yep. You're missing a REQUIRES/PRIV_REQUIRES line, as I said before. Change the CMakeLists.txt file in the http dir to
Code: Select all
idf_component_register(
SRCS "HTTP.cpp"
INCLUDE_DIRS .
REQUIRES esp_http_client
)
Re: esp_http_client.h: No such file or directory
Posted: Wed Oct 20, 2021 9:50 am
by imdaad
Thank you. That solved. I have two questions to ask.
1. This is my includes in WIFI library which resides in the same directory as of Http.
Code: Select all
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "esp_log.h"
#include "esp_event.h"
#include "esp_wifi.h"
but this didn't ask me to add anything to REQUIRES. Why is that?
2. How can I add more REQUIRES? Because I also included cJSON.h but it says no such file.
I tried few methods like space separation, comma separation. but it didn't catch that. Thank you
Re: esp_http_client.h: No such file or directory
Posted: Thu Oct 21, 2021 8:34 am
by ESP_Sprite
I don't know the answer to your first question... On the second one: the delimiter generally is a space, but do note that the thing you need to enter is a component name, which is the same as the base directory the component lives in. For instance, cJSON.h lives in esp-idf/components/json/cJSON/cJSON.h. The component name in this case would be 'json', so you'd need to fill that in.
Re: esp_http_client.h: No such file or directory
Posted: Thu Oct 21, 2021 8:59 am
by imdaad
thank you so much for your help. I learned a lot from you
Re: esp_http_client.h: No such file or directory
Posted: Fri Oct 22, 2021 8:14 am
by ESP_Sprite
No problem, glad I could help!