我正在尝试使用 websocketpp 库在 C++ 中处理 WebSocket。我已经在我的系统中克隆了这个库https://github.com/zaphoyd/websocketpp并使用“cmake -G”MinGW Makefiles”构建它。现在是我在这个存储库之外创建的源代码。
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
void on_message(websocketpp::connection_hdl hdl, server::message_ptr msg) {
std::cout << msg->get_payload() << std::endl;
}
int main() {
server print_server;
print_server.set_message_handler(&on_message);
print_server.init_asio();
print_server.listen(9002);
print_server.start_accept();
print_server.run();
}
正在抛出错误:
fatal error: websocketpp/config/asio_no_tls.hpp: No such file or directory
#include <websocketpp/config/asio_no_tls.hpp>
尽管此文件在目录中可用。因为我对这条线没有任何问题#include <websocketpp/server.hpp>
。单击选项更多我发现了这个错误
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit
任何人都可以帮助它完成需要做的事情。我在 VS 代码中编辑它并使用 MinGW。这是 properties.json 文件
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4