Boost logo

Boost Users :

Subject: Re: [Boost-users] Auto-Linking in Visual Studio 2008
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-01-04 06:58:52


> 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
> boost_thread*.dll.
>
> 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...

Are the dynamic libraries being specified on the linker command line?

You absolutely should not be linking to both (ie both auto-linking and
specifying the lib's on the command line).

So either disable auto-linking with BOOST_ALL_NO_LIB (you will need to
enable dynamic linking as well with BOOST_ALL_DYN_LINK if you want to use
the DLL's), or remove the library dependencies in CMake and let the
auto-linking do it's work. If you take the former route, be *very* careful
that your build script picks the correct lib variant, otherwise you're
likely to see crashes and other strange hard to track down behavior.....

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net