gpt4 book ai didi

c++ - 库包含 WinRT 损坏

转载 作者:行者123 更新时间:2023-12-02 18:39:56 28 4
gpt4 key购买 nike

我正在尝试编译这个项目:https://github.com/bucienator/ble-win-cpp

克隆存储库后,我收到错误“wait_for”不是“winrt::impl”的成员。使用 NuGet,我将 Microsoft.Windows.CppWinRT 包添加到项目中。但之后我对所有库的导入都中断了:

#include <winrt / Windows.Foundation.h>
#include <winrt / Windows.Devices.Bluetooth.h>
#include <winrt / Windows.Devices.Enumeration.h>
#include <winrt / Windows.Devices.Bluetooth.Advertisement.h>
#include <winrt / Windows.Devices.Bluetooth.GenericAttributeProfile.h>
#include <winrt / Windows.Storage.Streams.h>

告诉我如何让 Visual Studio 编译我的项目?

最佳答案

不确定它是如何编译的,但它已经有 3 年历史了,所以它可能是用较旧的 C++/WinRT 编译的。

这里提到了“wait_for”问题:https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47我的解决方案是添加 Microsoft.Windows.CppWinRT包。

然后你会遇到其他问题,你必须像这样修复 pch.h:

...
#include <iostream>
#include <sstream>
#include <iomanip>
#include <mutex> // add this
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h> // add this
#include <winrt/Windows.Devices.Bluetooth.h>
#include <winrt/Windows.Devices.Enumeration.h>
#include <winrt/Windows.Devices.Bluetooth.Advertisement.h>
#include <winrt/Windows.Devices.Bluetooth.GenericAttributeProfile.h>
#include <winrt/Windows.Storage.Streams.h>
...

关于c++ - 库包含 WinRT 损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68138854/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com