0

I'm trying to work on WebSocket in C++ using websocketpp library. I have cloned this library https://github.com/zaphoyd/websocketpp in my system and build it using "cmake -G "MinGW Makefiles". Now the source code which I have created outside this repository.

#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();
}

is throwing error:

fatal error: websocketpp/config/asio_no_tls.hpp: No such file or directory
 #include <websocketpp/config/asio_no_tls.hpp>

although this file is available in directory. Since I'm not getting any issue with this line #include <websocketpp/server.hpp>. Clicking on option more I found this error

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit

Anyone help it out with what needs to be done. I'm editing it in VS code and using MinGW. this is the properties.json file

"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
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Raman
  • 27
  • 4
  • Are you using CMake inside VSCode as your task? – drescherjm Apr 29 '21 at 18:24
  • yes. i guess. how to know it? @drescherjm – Raman Apr 29 '21 at 19:55
  • 1
    If you don't know I expect the answer is no and that you need to edit your `tasks.json` file. `c_cpp_properties.json` is for intellisense while `tasks.json` is for building. Each have independent include paths. The documentation here explains the files: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) – drescherjm Apr 29 '21 at 20:02
  • ok so what changes do i need to do in that file? @drescherjm – Raman Apr 29 '21 at 21:01
  • You need to add an argument to your compilers "args" for the include path of the library you built. You probably also have to add linker settings. This question may help: [https://stackoverflow.com/questions/52910102/vscode-c-task-json-include-path-and-libraries](https://stackoverflow.com/questions/52910102/vscode-c-task-json-include-path-and-libraries) – drescherjm Apr 29 '21 at 21:09

0 Answers0