这是一段代码,它是来自 cpp-netlib 的示例
#include <boost/network/protocol/http/server.hpp>
#include <string>
#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) {
std::string ip = source(request);
response = server::response::stock_reply(
server::response::ok, std::string("Hello, ") + ip + "!");
}
};
int
main(int argc, char * argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " address port" << std::endl;
return 1;
}
try {
hello_world handler;
server server_(argv[1], argv[2], handler);
server_.run();
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}
但是在编译时g++ main.cpp -o socke.exe -lboost_system
我得到以下错误
main.cpp:1:50: error: boost/network/protocol/http/server.hpp: No such file or directory
main.cpp:5: error: âboostâ has not been declared
我已经安装了 cpnet-lib 库和 cmake 来构建它们。我无法理解为什么编译器找不到库。