Search code examples
c++visual-studio-2012booststatic-linking

Unable to link to static boost library using VS2012 while dynamic linking works fine


I'm trying to statically link the boost library (boost/thread.hpp and boost/asio.hpp) to my project using VS2012 express. The build target is set to Windows XP (v110_xp) with the option Multithreaded (/MT) (static linking). The path to the boost libraries is set correctly in my project properties. (C:\Boost\boost_1_54_0\stage\lib) Nevertheless, I get the following linker error:

error LNK1104: file "libboost_system-vc110-mt-s-1_54.lib" cannot be opened.

This file is indeed missing in my library folder. However when linking dynamically using the Multithreaded-DLL (/MD) option, everything links fine. I originally build the boost library using the simple build method as described here: http://www.boost.org/doc/libs/1_54_0/more/getting_started/windows.html#simplified-build-from-source

bootstrap
.\b2

Since apperently the static library is missing, I called:

b2 --link=static

as describe here: http://www.boost.org/boost-build2/doc/html/bbv2/tutorial/linkage.html

This executes without an error, but does not seem to build anything new. What am I missing? Or is VS looking for a file that never exists? I was surprised to only get a handfull of hits when I was googling for the error and none of them really helped.


Solution

  • Invoke b2 with the following parameters:

    link=static runtime-link=static
    

    Note that there are no hyphens before link and runtime-link.