错误:无法打开包含文件:"MQTTAsync.h":没有此类文件或目录

Error: Cannot open include file: 'MQTTAsync.h': No such file or directory

本文关键字:文件 包含 MQTTAsync 错误      更新时间:2023-10-16

OS -Windows 10 x64

Library mqtt Microsoft Visual Studio Community 2017 版本 15.9.15

编程语言 - C++17

Installed paho-mqtt paho-mqttpp3paho-mqttpp3[ssl]using vcpkg

我正在使用 mqtt 创建一个 c++ 程序。 但是每当我在下面使用给定的标题时

#include <mqtt/async_client.h>

它给出以下错误

d:vcpkginstalledx64-windowsincludemqttasync_client.h(27): fatal error C1083: Cannot open include file: 'MQTTAsync.h': No such file or directory

但是MQTTAsync.h文件在给定的位置可用D:vcpkginstalledx64-windowsincludepaho-mqtt

我通过创建新的控制台项目点击了以下链接

https://github.com/Microsoft/vcpkg/issues/1848

仍然问题未得到解决

验证 vcpkg 目录中的名称是否正确。

就我而言,这将是C:UsersUSERNAMEvcpkginstalledx64-windowsincludepaho-mqtt

在这里,您将看到您要查找的头文件实际上称为MQTTAsync.h

要将其添加到您的项目中,您必须将

包含更改为#include <paho-mqtt/MQTTAsync.h>