How Boost automatically includes libraries

Boost is mostly a template based library, but using certain functionality requires linking with its libraries. On Windows, when you include a Boost header file in your code, it automatically generates a linking dependency on its corresponding library file. This library path is used by the linker to complete its linking operation.

For example, if I use the threading features of Boost, it generates a dependency on the library file: libboost_thread-vc110-mt-gd-1_53.lib.

This filename has various components: the Boost module, the Visual Studio version, the build type and the Boost version. These are obtained from various definitions in the boost/config/auto_link.hpp header file.

If you find that your code is looking for a Boost library filename that looks wrong in any way, then you might have to look into the above header file and configure some of the definitions.

For example, I built Boost 1.53 on Visual Studio 2013, even though it is not officially supported. When I used this Boost with my code, the linker complained that it was looking for libboost_thread-vc110-mt-gd-1_53.lib. This is strange, since I have built both Boost and my code using Visual Studio 2013 (vc120), but it is looking for Visual Studio 2012 (vc110). I found that the variable BOOST_LIB_TOOLSET was set to vc110 in auto_link.hpp. Changing this fixed the error.

Tried with: Boost 1.53, Visual Studio 2013 and Windows 7 x64


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.