我正在学习cpp-netlib,并尝试运行官方网站上提供的exmaple客户端。代码很简单:

#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;
}


这是我的C ++应用程序的makefile:
    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


它抱怨编译后找不到lboost_thread库:

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


在我的boost库目录中,boost_thread库显示如下:

libboost_thread-mt.a      libboost_thread-mt.dylib


为什么找不到该库?我在链接中没有犯任何错误吗?

最佳答案

尝试更改您的makefile以链接到-lboost-thread-mt而不是-lboost-thread。

您似乎由于某种原因缺少了libboost_thread

关于c++ - cpp-netlib提示缺少lboost线程,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30283017/

10-10 06:10