【问题标题】:Library includes WinRT brocken [closed]库包括 WinRT broken [关闭]
【发布时间】:2021-06-26 03:02:49
【问题描述】:

我正在尝试编译这个项目: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 编译我的项目?

【问题讨论】:

  • “所有库的导入都失败了”是什么意思?你有任何错误吗?

标签: c++ windows-runtime cppwinrt


【解决方案1】:

不确定它过去是如何编译的,但它已经有 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>
...    

【讨论】:

  • 我们的旧 Jenkins 服务器以某种方式优雅地处理了丢失的包,但是当切换到 Azure DevOps Pipelines 时,我们的 CppWinRT 服务之一开始中断。添加这个适用于 Windows 的 CppWinRT nuget 包让我畅通无阻。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-16
  • 2011-10-10
  • 1970-01-01
  • 1970-01-01
  • 2023-03-03
  • 1970-01-01
  • 2012-08-30
相关资源
最近更新 更多