简体   繁体   English

要链接到哪个 boost 库?

[英]Which boost library to link to?

Okay so I've got a very small program containing these three boost imports:好的,我有一个包含这三个 boost 导入的非常小的程序:

#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>

But that's just an example I'd like an answer that's applicable to other headers as well if possible.但这只是一个例子,如果可能的话,我想要一个也适用于其他标题的答案。 Now taking a look into /usr/lib results in a list of 39 static library objects I could possible link to (or rather put into my CMakeLists.txt): List of libraries现在查看 /usr/lib 会得到一个包含 39 个静态库对象的列表,我可以链接到(或者更确切地说是放入我的 CMakeLists.txt):库列表

How can I know which library is implementing which boost header in /usr/include/boost?我怎么知道哪个库在 /usr/include/boost 中实现了哪个 boost 头文件?

This is the relevant part of my CMakeLists.txt:这是我的 CMakeLists.txt 的相关部分:

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost
    1.63.0
    REQUIRED
    ????
)

Boost libraries has a naming convention defined in the documentation here . Boost 库具有在此处的文档中定义的命名约定。 Eg libboost_thread.a is a static library for Boost.Thread .例如libboost_thread.aBoost.Thread的静态库。

In the header source you can find related library name, eg in boost/thread.hpp there is:在头文件中你可以找到相关的库名,例如在boost/thread.hpp有:

//  See www.boost.org/libs/thread for documentation. 

Next you need to understand library is header-only or not.接下来您需要了解库是否仅包含头文件。 Check the list here .检查这里的列表。

Some libraries requires the other Boost libraries, eg Boost.Asio requires Boost.System and Boost.Regex in some cases.有些库需要其他 Boost 库,例如Boost.Asio在某些情况下需要Boost.SystemBoost.Regex Check library usage documentation to understand such dependencies.检查库使用文档以了解此类依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM