I'm trying to build my project that uses boost beast library with cmake. When I use only boost asio library everything builds okay. But when I add boost/beast/http.hpp header when cmake gives a huge amount of errors.
CMake file:
cmake_minimum_required(VERSION 3.10)
project(ConsoleChat.Server)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.75.0 REQUIRED COMPONENTS system filesystem)
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
add_executable(ConsoleChat.Server main.cpp)
target_link_libraries(ConsoleChat.Server ${Boost_LIBRARIES})
Code file:
#include <cstdlib>
#include <memory>
#include <thread>
#include <iostream>
#include <string>
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/beast/version.hpp>
#include <boost/beast/http.hpp>
namespace net = boost::asio;
namespace beast = boost::beast;
namespace http = beast::http;
using tcp = boost::asio::ip::tcp;
int main(int argc, char* argv[])
{
try
{
if (argc != 3)
{
std::cout <<
"Usage: websocket-chat-multi <address> <port>\n" <<
"Example:\n" <<
" websocket-chat-server 0.0.0.0 8080\n";
return EXIT_FAILURE;
}
auto const address = net::ip::address::from_string(argv[1]);//net::ip::make_address(argv[1]);
auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
net::io_service ios{1};
tcp::acceptor acceptor{ios, {address, port}};
for (;;)
{
tcp::socket socket{ios};
acceptor.accept(socket);
}
}
catch(const std::exception& e)
{
std::cout << e.what() << '\n';
}
}
Example of error:
In file included from /usr/local/include/boost/beast/core/buffer_traits.hpp:14,
from /usr/local/include/boost/beast/http/basic_dynamic_body.hpp:14,
from /usr/local/include/boost/beast/http.hpp:15,
from /home/kudryavii/projects/ConsoleChat/ConsoleChat.Server/main.cpp:10:
/usr/local/include/boost/beast/core/detail/buffer_traits.hpp:66:18: error: ‘is_const_buffer_sequence’ is not a member of ‘boost::beast::net’
66 | net::is_const_buffer_sequence<B>::value>::type>
| ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/beast/core/detail/buffer_traits.hpp:66:18: error: ‘is_const_buffer_sequence’ is not a member of ‘boost::beast::net’
I tried to add all boost libraries to find package section but this didn't help.