Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When ASIO_STANDALONE is defined it still asks for <boost/thread.hpp> #980

Open
debruss opened this issue Apr 9, 2021 · 9 comments
Open

Comments

@debruss
Copy link

debruss commented Apr 9, 2021

When trying to compile my program with the following (like in the client example.):

#define ASIO_STANDALONE
#include "websocketpp/client.hpp"
#include "websocketpp/config/asio_no_tls_client.hpp"

Returns the error that

[rest_of_path_omitted]/websocketpp/common/thread.hpp:63:14: fatal error: boost/thread.hpp: No such file or directory
[build]      #include <boost/thread.hpp>
[build]               ^~~~~~~~~~~~~~~~~~

I have verified that the standalone Asio headers are correctly included.

It is compiled on Windows using GCC 8.1.0 with C++17. Is it possible that there might be a bug here?

@gocpplua
Copy link

do you link?

@debruss
Copy link
Author

debruss commented Apr 13, 2021

@gocpplua Yes I have verified that the standalone headers are included, but by using the ASIO_STANDALONE flag I should not have to use <boost/thread.hpp> right? I thought that was the idea of the standalone functionality.

@zaphoyd
Copy link
Owner

zaphoyd commented Jun 29, 2021

WIth Asio in standalone mode no boost libraries are required. Compiling in C++11 or later mode with a C++11 or later standard library is required. You will need to explicitly make sure that you are specifying a C++11 or later target via -std=c++17 or however your compiler specifies that. That said, it sounds like you are compiling with C++17 mode on gcc which should support C++11 threads out of the box.

As such I'm not sure why it isn't picking them up? You can try forcing it by defining _WEBSOCKETPP_CPP11_THREAD_ (force the thread feature only) and/or _WEBSOCKETPP_CPP11_STRICT_ (force all C++11 features) but those shouldn't be necessary. If you are still having this issue I can supply a simple test file to try compiling that may work through the logic tree and figure out how to autodetect C++11 threads in your environment. (I've worked with gcc on linux and MSVC on Windows but not gcc on Windows).

@HolyBugger
Copy link

it works

@LegendOfCatBro
Copy link

I am attempting to install. a library with asio and websocketpp as dependencies with GCC 8.1.0 on windows, and am encountering the exact same error.

@8Observer8
Copy link

8Observer8 commented Sep 3, 2022

I have the same error in Qt Creator. I download the "websocketpp-0.8.2" folder and renamed it to "websocketpp-0.8.2-headers":

pro


CONFIG += c++11

INCLUDEPATH += "E:\Libs\websocketpp-0.8.2-headers"

SOURCES += \
    main.cpp

main.cpp

#define ASIO_STANDALONE

#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>

typedef websocketpp::client<websocketpp::config::asio_client> client;

using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;

int main()
{
    std::cout << "hello" << std::endl;
    return 0;
}

image

E:\Libs\websocketpp-0.8.2-headers\websocketpp\common\thread.hpp:63: error: boost/thread.hpp: No such file or directory
In file included from E:/Libs/websocketpp-0.8.2-headers/websocketpp/concurrency/basic.hpp:31,
                 from E:/Libs/websocketpp-0.8.2-headers/websocketpp/config/core_client.hpp:38,
                 from E:/Libs/websocketpp-0.8.2-headers/websocketpp/config/asio_no_tls_client.hpp:31,
                 from ..\..\websockets\C++\websocketpp_example\main.cpp:3:
E:/Libs/websocketpp-0.8.2-headers/websocketpp/common/thread.hpp:63:14: fatal error: boost/thread.hpp: No such file or directory
     #include <boost/thread.hpp>
              ^~~~~~~~~~~~~~~~~~

@8Observer8
Copy link

8Observer8 commented Sep 3, 2022

it by defining _WEBSOCKETPP_CPP11_THREAD_ (force the thread feature only) and/or _WEBSOCKETPP_CPP11_STRICT_ (force all C++11 features)

I tried it too. I have this error now:

image

E:\Libs\websocketpp-0.8.2-headers\websocketpp\common\asio.hpp:46: error: asio/version.hpp: No such file or directory
In file included from E:/Libs/websocketpp-0.8.2-headers/websocketpp/transport/asio/base.hpp:31,
                 from E:/Libs/websocketpp-0.8.2-headers/websocketpp/transport/asio/connection.hpp:31,
                 from E:/Libs/websocketpp-0.8.2-headers/websocketpp/transport/asio/endpoint.hpp:32,
                 from E:/Libs/websocketpp-0.8.2-headers/websocketpp/config/asio_no_tls_client.hpp:32,
                 from ..\..\websockets\C++\websocketpp_example\main.cpp:5:
E:/Libs/websocketpp-0.8.2-headers/websocketpp/common/asio.hpp:46:14: fatal error: asio/version.hpp: No such file or directory
     #include <asio/version.hpp>
              ^~~~~~~~~~~~~~~~~~

pro


CONFIG += c++11

INCLUDEPATH += "E:\Libs\websocketpp-0.8.2-headers"

SOURCES += \
    main.cpp

main.cpp

#define ASIO_STANDALONE
#define _WEBSOCKETPP_CPP11_THREAD_
#define _WEBSOCKETPP_CPP11_STRICT_

#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>

typedef websocketpp::client<websocketpp::config::asio_client> client;

using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;

int main()
{
    std::cout << "hello" << std::endl;
    return 0;
}

@RavazziniAndrea
Copy link

@8Observer8, I have the same problem. Did you find a solution?

@8Observer8
Copy link

8Observer8 commented Nov 8, 2024

@8Observer8, I have the same problem. Did you find a solution?

No, but I found another library. I had a problem with that library too, but I solved it: machinezone/IXWebSocket#529 (comment)

Another solution is curl. I had a problem but I've solved it here: curl/curl#14926 (comment)
The official example to use curl with WebSockets: https://curl.se/libcurl/c/websocket.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants