0

I'm learning cpp-netlib and I tried running the exmaple client given on the official website. The code is very simple:

#include <boost/network/protocol/http/client.hpp>
#include <iostream>
int main(int argc, char *argv[]) {
    using namespace boost::network;

    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " [url]" << std::endl;
        return 1;
    }

    http::client client;
    http::client::request request(argv[1]);
    request << header("Connection", "close");
    http::client::response response = client.get(request);
    std::cout << body(response) << std::endl;
    return 0;
}

And here is my makefile for this c++ application: CC = g++ -std=c++11

CFLAG = -I/usr/local/Cellar/boost/1.57.0/include
LIBFLAG = -L/usr/local/Cellar/boost/1.57.0/lib  

all: client

client: client.o
    $(CC) $(LIBFLAG) -lboost_system -lboost_thread client.o -o client  

client.o: client.cpp
    $(CC) -c $(CFLAG) client.cpp

clean:
    rm -rf *.o client

It complains about not finding lboost_thread library after compilation:

ld: library not found for -lboost_thread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [client] Error 1

In my boost library directory, the boost_thread library shows up like this:

libboost_thread-mt.a      libboost_thread-mt.dylib  

Why isn't it able to find this library? Did I make any mistake in the linking?

1
  • Try using -lboost_thread-mt in place of -lboost_thread option? Commented May 17, 2015 at 3:32

1 Answer 1

1

Try changing your makefile to link to -lboost-thread-mt instead of -lboost-thread.

You seems to be missing libboost_thread for some reason

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.