【发布时间】:2015-04-15 08:04:17
【问题描述】:
这是一段来自 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 来构建它们。我无法理解为什么编译器找不到库。
【问题讨论】:
-
你也安装了 boost 库吗?
-
是的 boost_1_56_0.7 已安装。
-
是否在 LIBPATH 中更新了 boost lib 路径?
-
是的,它是 export PATH=$PATH:/usr/local/include/:/usr/local/lib/ 问题是当我在系统上找到文件时我自己找不到文件
-
还有另一个名为 LIBPATH 的环境变量,请更新那个。它不是 PATH。
标签: c++ linux boost cpp-netlib