0
不會編譯我試圖用CPP-NETLIB-0.12.0上cpp-netlib.org運行Hello World例子並提高-1.64.0在Ubuntu 16.04。一塊的代碼是(從第1行):CPP-NETLIB Hello World示例在Linux上
#include <boost/network/protocol/http/server.hpp>
#include <iostream>
namespace http = boost::network::http;
struct hello_world;
typedef http::server<hello_world> server;
struct hello_world
{
void operator()(server::request const &request, server::response &response)
{
server::string_type ip = source(request);
unsigned int port = request.source_port;
std::ostringstream data;
data << "Hello, " << ip << ':' << port << '!';
response = server::response::stock_reply(server::response::ok, data.str());
}
void log(const server::string_type& message)
{
std::cerr << "ERROR: " << message << std::endl;
}
};
,當我使用下面的行來編譯:
g++ test1.cpp -o test1 -std=c++11 -lcppnetlib-uri -lcppnetlib-server-parsers -lcppnetlib-client-connections -lboost_system -lboost_thread -lpthread
我得到以下錯誤:
test1.cpp:11:61: error: ‘boost::network::http::server<hello_world>::response’ has not been declared
void operator()(server::request const &request, server::response &response)
^
test1.cpp: In member function ‘void hello_world::operator()(const request&, int&)’:
test1.cpp:17:28: error: ‘boost::network::http::server<hello_world>::response’ has not been declared
response = server::response::stock_reply(server::response::ok, data.str());
^
test1.cpp:17:58: error: ‘boost::network::http::server<hello_world>::response’ has not been declared
response = server::response::stock_reply(server::response::ok, data.str());
^
我從網站的例子中拿出代碼。我檢查了包含路徑和所有必要的庫似乎在那裏。我似乎無法弄清楚問題所在。