cpp-netlib 抱怨缺少 lboost-thread

cpp-netlib complains about missing lboost-thread

我正在学习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 link 更改为 -lboost-thread-mt 而不是 -lboost-thread。

你好像失踪了 libboost_thread 出于某种原因