2

I am trying to compile this project: https://github.com/bucienator/ble-win-cpp

After cloning the repository, I got the error "wait_for" is not a member of "winrt :: impl". Using NuGet, I added the Microsoft.Windows.CppWinRT package to the project. But after that my imports of all libraries broke:

#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>

Tell me how do I get Visual Studio to compile my project?

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
xikov
  • 89
  • 8
  • What do you mean with "the imports of all libraries broke"? Do you get any errors? – PMF Oct 18 '21 at 14:50

1 Answers1

5

Not sure how this used to compile but it's 3 years old so it's possible it compiled with an older C++/WinRT.

The "wait_for" issue is mentioned here: https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47 and my solution is to add the Microsoft.Windows.CppWinRT package.

Then you will have other issues and you have to fix the pch.h like this:

...
#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>
...    
Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • 1
    Somehow our old Jenkins server was gracefully handling the missing packages, but when switching to Azure DevOps Pipelines one of our CppWinRT services started to break. Adding in this CppWinRT nuget package for Windows unblocked me. Thanks! – kayleeFrye_onDeck Oct 16 '21 at 17:20
  • If you don't want to install the nuget package, use the following workaround: https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/47#issuecomment-668381574 The next comment explains what's happening. – n0p May 02 '22 at 12:01