如何从 Visual Studio C++ 使用 uWebsockets?

How to use uWebsockets from Visual Studio C++?

uWebSockets https://github.com/uNetworking/uWebSockets

如何在 Visual Studio C++ 中使用它?我想实现一个简单的 websocket 服务器。我不想使用 Makefile,希望使用正常的 visual studio 项目构建。

这是如何在 Visual C++ IDE 项目中使用 uWebsockets,一步一步:

  1. 安装 Vcpkg https://github.com/microsoft/vcpkg
    然后命令行如下
  2. set VCPKG_DEFAULT_TRIPLET=x64_windows
  3. vcpkg install uwebsockets

此时有一个文件夹vcpkg\installed\x64-windows,其中包含头文件和库文件以及dll(如果您需要dll)。

在您的 Visual C++ 项目属性中,在 VC 目录中设置 include 目录和 lib 目录。

然后 #include <uwebsockets/App.h> 并粘贴来自 uwebsockets 的代码。