Boost logo

Boost Users :

Subject: [Boost-users] Auto-Linking in Visual Studio 2008
From: Robert Abel (abel_at_[hidden])
Date: 2012-01-03 15:40:18


I recently began using boost in a project on Windows using MS Visual
Studio 9.0 2008 using CMake, i.e. the project setup is auto-generated
using the correct boost libraries as link targets. In my project, I link
to boost_thread*.lib, which should be the import library for

However, when I compile the project, the I get the following linking error:

> Error 43 fatal error LNK1104: cannot open file
> 'libboost_thread-vc90-mt-1_48.lib' rsb-chat-1 rsb-chat-1

So it seems necessary to have the static library present as well when
linking the executable. At first I thought this was the default
auto-linking behavior described in the documentation, i.e. static
linking. However, once all needed static libraries are supplied, the
final executable still needs the dynamic boost_*.dll libraries. This did
not seem right to me...

Now, when I disable auto-linking using

> #define BOOST_ALL_NO_LIB

the linker will not try to link the static libboost_thread*.lib, but
instead use the boost_thread*.lib that was defined in the project settings.

I couldn't find any documentation on this specific auto-linking behavior.

  * Is this expected behavior? Maybe MSVS-specific behavior?
  * Does the presence of the static library actually preclude some
    dynamic linking from occurring, thus making my executable bigger?
  * Or does the static library basically just need to be present and
    auto-linking will actually not use it when it's not appropriate?
  * Or does auto-linking mix and match, i.e. in my original case, when I
    supplied the static libraries: Did it link some functions
    statically, while others dynamically?



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at