Boost tuple, linker error on Mac OS X 10.7

351 Views Asked by At

I have compiled boost 1.49.0 from source on a MacBook Pro running Mac OS X 10.7.3, I use Xcode 4.3.2 and Apple's LLVM 3.1 as my development environment. The following line of code (from boost http server1 example) results in a linking error as described:

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)

I searched the answers but I couldn't find anything related to it, neither I understand why the error is happening. The project links against lboost_system. Am I missing something? I am new to boost libraries.

1

There are 1 best solutions below

0
On

It turns out my problem wasn't in this method, I mistakenly had RequestParser.parse() in the class implementation, checking back with the boost example the method is implemented in the declaration of the class.