c++ - 库包括 WinRT Broken
问题描述
我正在尝试编译这个项目: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>
...
推荐阅读
- gradle - 在 gradle 中是否可以根据标志包含不同的 jar
- multithreading - 如何在 UML 序列图中修改两个以上的并行线程
- asp.net-core - ASP.NET 核心 - 仅在没有控制器时才激活路由处理程序
- javascript - 如果这个人的名字中有这个表情符号,他们应该扮演这个角色。(来自写入数据库的表情符号)
- asp.net-core - ASP.NET Core RBAC 与客户端凭据流 (OIDC) 混合
- kotlin - Kotlin Multiplatform 中复合构建的未解决参考
- python - 正则表达式 - 在特定字符串后获取值
- javascript - Middy API,使用 jsonBodyParser 中间件返回对象
- python - 我试图打印出这个简单的方程式,但它说浮动对象不可调用
- javascript - Sequelize 从外键获取 N:M 关联