Ошибка при компиляции проекта с boost?

294
29 апреля 2022, 15:10

Не собирается программа код ниже:

#include <boost/beast.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <string>
#include <iostream>
using namespace std;
namespace http = boost::beast::http;
int main(int argc, char* argv[])
{
    boost::asio::io_context io;
    boost::asio::ip::tcp::resolver resolver(io);
    boost::asio::ip::tcp::socket socket(io);
    boost::asio::connect(socket, resolver.resolve("google.com", "80"));
    http::request<http::string_body> req(http::verb::get, "/", 11);
    req.set(http::field::host, "google.com");
    req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
    http::write(socket, req);
    string response;
    {
        boost::beast::flat_buffer buffer;
        http::response<http::dynamic_body> res;
        http::read(socket, buffer, res);
        response = boost::beast::buffers_to_string(res.body().data());
    }
    socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both);
    cout << response;
    return 0;
}

Компилировал при помощи g++

Версия g++

g++ (MinGW.org GCC-6.3.0-1) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Команда:

g++ -I Z:\boostEnd\boost_1_74_0 -L Z:\boostEnd\boost_1_74_0\lib64-msvc-14.1 main.cpp -o test

Ну и ошибка:

In file included from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.hpp:47:0,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/hybi13.ipp:15,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/hybi13.hpp:45,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/stream.hpp:19,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket.hpp:18,
                 from Z:\boostEnd\boost_1_74_0/boost/beast.hpp:18,
                 from main.cpp:4:
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp: In function 'uint32_t boost::beast::websocket::detail::secure_generate()':
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:92:14: error: 'mutex' in namespace 'std' does not name a type
         std::mutex mtx;
              ^~~~~
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp: In member function 'uint32_t boost::beast::websocket::detail::secure_generate()::generator::operator()()':
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:87:29: error: 'mutex' is not a member of 'std'
             std::lock_guard<std::mutex> guard{mtx};
                             ^~~
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:87:29: note: suggested alternative:
In file included from Z:\boostEnd\boost_1_74_0/boost/asio/execution/blocking_adaptation.hpp:20:0,
                 from Z:\boostEnd\boost_1_74_0/boost/asio/execution.hpp:22,
                 from Z:\boostEnd\boost_1_74_0/boost/asio/system_executor.hpp:20,
                 from Z:\boostEnd\boost_1_74_0/boost/asio/associated_executor.hpp:22,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core/detail/bind_handler.hpp:16,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core/bind_handler.hpp:14,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core/async_base.hpp:14,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core.hpp:15,
                 from Z:\boostEnd\boost_1_74_0/boost/beast.hpp:15,
                 from main.cpp:4:
Z:\boostEnd\boost_1_74_0/boost/asio/detail/mutex.hpp:39:19: note:   'boost::asio::detail::mutex'
 typedef win_mutex mutex;
                   ^~~~~
In file included from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.hpp:47:0,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/hybi13.ipp:15,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/hybi13.hpp:45,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/stream.hpp:19,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket.hpp:18,
                 from Z:\boostEnd\boost_1_74_0/boost/beast.hpp:18,
                 from main.cpp:4:
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:87:29: error: 'mutex' is not a member of 'std'
             std::lock_guard<std::mutex> guard{mtx};
                             ^~~
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:87:29: note: suggested alternative:
In file included from Z:\boostEnd\boost_1_74_0/boost/asio/execution/blocking_adaptation.hpp:20:0,
                 from Z:\boostEnd\boost_1_74_0/boost/asio/execution.hpp:22,
                 from Z:\boostEnd\boost_1_74_0/boost/asio/system_executor.hpp:20,
                 from Z:\boostEnd\boost_1_74_0/boost/asio/associated_executor.hpp:22,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core/detail/bind_handler.hpp:16,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core/bind_handler.hpp:14,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core/async_base.hpp:14,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/core.hpp:15,
                 from Z:\boostEnd\boost_1_74_0/boost/beast.hpp:15,
                 from main.cpp:4:
Z:\boostEnd\boost_1_74_0/boost/asio/detail/mutex.hpp:39:19: note:   'boost::asio::detail::mutex'
 typedef win_mutex mutex;
                   ^~~~~
In file included from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.hpp:47:0,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/hybi13.ipp:15,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/hybi13.hpp:45,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket/stream.hpp:19,
                 from Z:\boostEnd\boost_1_74_0/boost/beast/websocket.hpp:18,
                 from Z:\boostEnd\boost_1_74_0/boost/beast.hpp:18,
                 from main.cpp:4:
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:87:39: error: template argument 1 is invalid
             std::lock_guard<std::mutex> guard{mtx};
                                       ^
Z:\boostEnd\boost_1_74_0/boost/beast/websocket/detail/prng.ipp:87:47: error: 'mtx' was not declared in this scope
             std::lock_guard<std::mutex> guard{mtx};
READ ALSO
SFML: улавливание кириллицы в TextEntered

SFML: улавливание кириллицы в TextEntered

Если использовать код из официальной документации SFML

213
Парсер файлов настроек

Парсер файлов настроек

Есть одна проблемка, я попытался написать свой парсер для чтения таких файлов:

256
Memcpy - немного непонятно работает

Memcpy - немного непонятно работает

Позвольте пожалуйста еще один вопрос по скорости работы функции, в данном случае это memcpy

154
Изменить this в методе класса с++

Изменить this в методе класса с++

Ситуация такова, внутри метода класса List удаляю объект, с которым работаю, а после этого хочу запустить конструктор копирования для этого...

159