Til Blechschmidt
Til Blechschmidt

Reputation: 111

Which boost library to link to?

Okay so I've got a very small program containing these three boost imports:

#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

How can I know which library is implementing which boost header in /usr/include/boost?

This is the relevant part of my 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
    ????
)

Upvotes: 5

Views: 2901

Answers (1)

Nikita
Nikita

Reputation: 6427

Boost libraries has a naming convention defined in the documentation here. E.g. libboost_thread.a is a static library for Boost.Thread.

In the header source you can find related library name, e.g. in boost/thread.hpp there is:

//  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, e.g. Boost.Asio requires Boost.System and Boost.Regex in some cases. Check library usage documentation to understand such dependencies.

Upvotes: 4

Related Questions