websocketpp icon indicating copy to clipboard operation
websocketpp copied to clipboard

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

Open debruss opened this issue 4 years ago • 10 comments

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?

debruss avatar Apr 09 '21 10:04 debruss

do you link?

gocpplua avatar Apr 13 '21 09:04 gocpplua

@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.

debruss avatar Apr 13 '21 09:04 debruss

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).

zaphoyd avatar Jun 29 '21 14:06 zaphoyd

it works

HolyBugger avatar Nov 05 '21 10:11 HolyBugger

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.

LegendOfCatBro avatar Feb 04 '22 16:02 LegendOfCatBro

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 avatar Sep 03 '22 23:09 8Observer8

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;
}

8Observer8 avatar Sep 03 '22 23:09 8Observer8