Page 1 of 1

error: mqtt_client.h: No such file or directory

Posted: Wed Nov 03, 2021 12:47 pm
by lg.lindstrom
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 ????

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

Posted: Thu Nov 04, 2021 9:34 am
by lg.lindstrom
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 ???

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

Posted: Thu Nov 04, 2021 1:06 pm
by lg.lindstrom
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"

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

Posted: Fri Nov 05, 2021 1:45 am
by ESP_Sprite
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.

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

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

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

Posted: Sun Nov 07, 2021 1:44 pm
by lg.lindstrom
Thanks.

How to know when to use :
REQUIRES xxxx

Normally ESP-IDF stuff is added automagically :)

Thanks again.

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

Posted: Mon Nov 08, 2021 12:57 am
by 山竹君_kk
当你需要某种功能,比如examples目录下的那些项目的功能时就需要添加对应的子模块到REQUARS里。或者你加了某些功能但出现了你现在这样的错误就可能需要添加对应的子模块