0

I have been trying to get this small program to work but keep getting compiler errors. I am using VS 2019 on windows and following this document. The program just gets the header of www.example.com and outputs the body response using the cpp-netlib library.

#include <boost/network/protocol/http/client.hpp>
#include <string>
#include <iostream>

int main()
{
    boost::network::http::client client;
    boost::network::http::client::request request("http://www.example.com");
    request << boost::network::header("Connection", "close");
    boost::network::http::client::response response = client.get(request);

    std::cout << body(response);
}

I get the following errors from VS:

Error   C2039   'get_io_service': is not a member of 'boost::asio::ip::basic_resolver<boost::asio::ip::udp,boost::asio::any_io_executor>'   Project2    C:\Program Files\cpp-netlib\cpp-netlib-0.13.0-final\boost\network\protocol\http\client\connection\async_base.hpp    62  

Error   C3536   'delegate': cannot be used before it is initialized Project2    C:\Program Files\cpp-netlib\cpp-netlib-0.13.0-final\boost\network\protocol\http\client\connection\async_base.hpp    67  

But the documentation says to compile using CMake which I have tried but cannot get it to work. Any help at all would be greatly appreciated.

  • 1
    For the first error, it looks like boost removed the function in boost 1.70. Related: [https://github.com/rstudio/rstudio/issues/4636](https://github.com/rstudio/rstudio/issues/4636) and [https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/history.html](https://www.boost.org/doc/libs/1_70_0/doc/html/boost_asio/history.html) – drescherjm Nov 14 '21 at 16:13
  • 1
    Also related: [https://github.com/cpp-netlib/cpp-netlib/issues/875](https://github.com/cpp-netlib/cpp-netlib/issues/875) – drescherjm Nov 14 '21 at 16:17
  • 1
    There is a patch linked here: [https://gist.github.com/Legodev/9c745b7ddf0f809bd990e72c8e6a2f9d](https://gist.github.com/Legodev/9c745b7ddf0f809bd990e72c8e6a2f9d) – drescherjm Nov 14 '21 at 16:19

0 Answers0