我在运行Mac OS X 10.7.3的MacBook Pro上从源代码编译了boost 1.49.0,我使用Xcode 4.3.2和Apple的LLVM 3.1作为我的开发环境。下面的代码行(来自boosthttpserver1示例)导致如下所述的链接错误:
void Connection::handleRead(const boost::system::error_code& error, size_t bytesTransfered) {
if (!error) {
boost::tribool result;
boost::tie(result, boost::tuples::ignore) = requestParser.parse(request, buffer.data(), buffer.data() + bytesTransfered);
if (result) {
requestHandler.handleRequest(request, reply);
async_write(socket, reply.toBuffers(), boost::bind(&Connection::handleWrite, shared_from_this(), placeholders::error));
}
else if (!result) {
reply = Reply::stockReply(Reply::badRequest);
async_write(socket, reply.toBuffers(), boost::bind(&Connection::handleWrite, shared_from_this(), placeholders::error));
}
else {
socket.async_read_some(boost::asio::buffer(buffer), boost::bind(&Connection::handleRead, shared_from_this(), placeholders::error, placeholders::bytes_transferred));
}
}
else if (error != error::operation_aborted) {
connectionManager.stop(shared_from_this());
}
}
Undefined symbols for architecture x86_64:
"boost::tuples::tuple<boost::logic::tribool, char*, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> RequestParser::parse<char*>(Request&, char*, char*)", referenced from:
Connection::handleRead(boost::system::error_code const&, unsigned long) in Connection.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我搜索了答案,但找不到任何相关的东西,也不明白为什么会出现错误。项目链接到lbostrongystem。我是不是错过了什么?我是新来推动图书馆事业的。
事实证明,我的问题不在这个方法中,我错误地在类实现中使用了RequestParser.parse(),通过boost示例查看该方法是在类的声明中实现的。