error: mqtt_client.h: No such file or directory

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

error: mqtt_client.h: No such file or directory

Postby lg.lindstrom » Wed Nov 03, 2021 12:47 pm

Hi

I am running esp-idf 4.1 with vsCode.

The compiler cant find mqtt_client.h
Using a file browse I can see that the file is there,,,, so it must be something wrong with my configuration.
What should I look for ????

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Re: error: mqtt_client.h: No such file or directory

Postby lg.lindstrom » Thu Nov 04, 2021 9:34 am

I've learned a bit more, but still not solved my problem.

When I started the project it was as a arduino-esp32 project. I had a lot of legacy code from before that I used. I have replaced most of my arduino code and was in the process to replace the asyncMqttClient when I run into this problem.

My guess is that my problem have to do with sdkConfig file and how it is configured. Unfortunately using "menuconfig" I cant find any parameter that can be changed to help me.


Is there a description for deeper understanding of sdkconfig ???

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Re: error: mqtt_client.h: No such file or directory

Postby lg.lindstrom » Thu Nov 04, 2021 1:06 pm

I did this.

I created a new ESP project using MQTT template.
Compiled it,, worked fine.

Then I copied all my component from the old project.

Compiled it,,, same error showed up => "fatal error: mqtt_client.h: No such file or directory"

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

Re: error: mqtt_client.h: No such file or directory

Postby ESP_Sprite » Fri Nov 05, 2021 1:45 am

Are you using mqtt in one of your components (that is, not the 'main' component)? In that case, you need to add it to the REQUIRES section. See the docs for more info.

User avatar
山竹君_kk
Posts: 17
Joined: Mon Nov 01, 2021 2:33 am

Re: error: mqtt_client.h: No such file or directory

Postby 山竹君_kk » Fri Nov 05, 2021 6:49 am

这种情况可能有用的解决方法是往你自己工程文件夹中main文件夹下面的CMakeLists.txt文件中idf_component_register这行下面的REQUIRES后面添加缺少的头文件所对应的子模块而子模块的名称为esp-idf-vx.x目录下components目录内模块的名称。例如你这里就是添加“mqtt” 。
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS .
REQUIRES mqtt)
也许有用,可以试试。

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Re: error: mqtt_client.h: No such file or directory

Postby lg.lindstrom » Sun Nov 07, 2021 1:44 pm

Thanks.

How to know when to use :
REQUIRES xxxx

Normally ESP-IDF stuff is added automagically :)

Thanks again.

User avatar
山竹君_kk
Posts: 17
Joined: Mon Nov 01, 2021 2:33 am

Re: error: mqtt_client.h: No such file or directory

Postby 山竹君_kk » Mon Nov 08, 2021 12:57 am

当你需要某种功能,比如examples目录下的那些项目的功能时就需要添加对应的子模块到REQUARS里。或者你加了某些功能但出现了你现在这样的错误就可能需要添加对应的子模块

Who is online

Users browsing this forum: Bing [Bot] and 97 guests