esp_http_client.h: No such file or directory

imdaad
Posts: 10
Joined: Mon Oct 26, 2020 12:58 pm

esp_http_client.h: No such file or directory

Postby imdaad » Sun Oct 17, 2021 4:05 pm

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.
Attachments
Screenshot 2021-10-17 213429.png
Screenshot 2021-10-17 213429.png (13.77 KiB) Viewed 9533 times

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: esp_http_client.h: No such file or directory

Postby ESP_Sprite » Mon Oct 18, 2021 1:00 am

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?

imdaad
Posts: 10
Joined: Mon Oct 26, 2020 12:58 pm

Re: esp_http_client.h: No such file or directory

Postby imdaad » Tue Oct 19, 2021 9:05 am

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.

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: esp_http_client.h: No such file or directory

Postby ESP_Sprite » Tue Oct 19, 2021 10:52 am

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?

imdaad
Posts: 10
Joined: Mon Oct 26, 2020 12:58 pm

Re: esp_http_client.h: No such file or directory

Postby imdaad » Tue Oct 19, 2021 12:28 pm

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?

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: esp_http_client.h: No such file or directory

Postby ESP_Sprite » Wed Oct 20, 2021 1:23 am

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
)

imdaad
Posts: 10
Joined: Mon Oct 26, 2020 12:58 pm

Re: esp_http_client.h: No such file or directory

Postby imdaad » Wed Oct 20, 2021 9:50 am

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.

Code: Select all

REQUIRES esp_http_client 
I tried few methods like space separation, comma separation. but it didn't catch that. Thank you

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: esp_http_client.h: No such file or directory

Postby ESP_Sprite » Thu Oct 21, 2021 8:34 am

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.

imdaad
Posts: 10
Joined: Mon Oct 26, 2020 12:58 pm

Re: esp_http_client.h: No such file or directory

Postby imdaad » Thu Oct 21, 2021 8:59 am

thank you so much for your help. I learned a lot from you

ESP_Sprite
Posts: 9715
Joined: Thu Nov 26, 2015 4:08 am

Re: esp_http_client.h: No such file or directory

Postby ESP_Sprite » Fri Oct 22, 2021 8:14 am

No problem, glad I could help!

Who is online

Users browsing this forum: Google [Bot] and 414 guests