0

框架:

ESP-IDF v4.3.1 - Eclipse 插件

具有 1 个活动组件的项目(我的计划是添加 ble 扫描、mqtt 消息传递和 wifi 访问)

IDF_PATH:        C:\Users\username\source\esp-idf-v4.3.1\
IDF_TOOLS_PATH:  C:\Users\username\.espressif

目标: 为 ESP-IDF 中的自定义组件添加 MQTT 功能

问题:

../components/mqtt/include/mqtt.h:24:10: fatal error: mqtt_client.h: No such file or directory
 #include "mqtt_client.h"

项目目录内容:

在此处输入图像描述

/components/mqtt/CMakeLists.txt的内容:

idf_component_register(SRCS "mqtt.c"
                        INCLUDE_DIRS "include"
                        REQUIRES mqtt esp-tls)

我按照此处 ESP-IDF 文档的指示将 mqtt 和 esp-tls 所需的组件添加到 CMakeLists.txt 文件中:https ://docs.espressif.com/projects/esp-idf/en/latest/esp32/api- guides/build-system.html#idf-component-commands

尝试修复 1 我第一次尝试修复此代码是更新 /components/mqtt/CMakeLists.txt 的内容以直接引用所需的包含文件:

idf_component_register(SRCS 
                        "mqtt.c"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/mqtt/esp-mqtt/mqtt_client.c"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/esp-mqtt/lib/mqtt_msg.c"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/esp-mqtt/lib/mqtt_outbox.c"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/esp-mqtt/lib/platform_esp32_idf.c"
                    INCLUDE_DIRS 
                        "include"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/mqtt/esp-mqtt/include" 
                        "C:/Users/user/source/esp-idf-v4.3.1/components/esp-tls"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/mbedtls/mbedtls/include"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/mbedtls/port/include"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/tcp_transport/include"
                        "C:/Users/user/source/esp-idf-v4.3.1/components/nghttp/port/include"
                    PRIV_INCLUDE_DIRS "C:/Users/user/source/esp-idf-v4.3.1/components/mqtt/esp-mqtt/lib/include" 
                    REQUIRES lwip nghttp mbedtls)

这可以构建,但必须有更好的方法来构建 mqtt 组件。谁能帮我修改我的 CMakeLists.txt 文件以正确拉入 esp-idf mqtt 组件?

4

1 回答 1

1

您有命名冲突。您正在尝试创建一个名为的自定义组件mqtt,该组件需要名为的系统组件mqtt,并且您希望构建系统能够解决它。那只是自找麻烦:)

命名您的组件myproject-mqtt或其他名称。注意您的组件wifible.

于 2021-11-18T11:27:31.997 回答