Search code examples
c++visual-studio-2008booststatic-linkingboost-python

Boost autolinks libraries which are not built by Boost, but the intended ones are built


I am developing a Math application which can be extended by writing python scripts.

I am using Qt 4.6.3 (built as static library, debug and release versions) and Boost 1.43.0 (built as static library, runtime-link also set to static, multi-threaded version, debug and release). Everything is built with MSVC++2008. Boost built the following libraries:

  • libboost_python-vc90-mt-s-1_43.lib
  • libboost_python-vc90-mt-s.lib
  • libboost_python-vc90-mt-sgd-1_43.lib
  • libboost_python-vc90-mt-sgd.lib

My project compiles, but gives the following error during the linking phase:

1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'boost_python-vc90-mt-gd-1_43.lib'

Why is it not selecting one of my compiled libraries?

I think the s in the library names stands for static, but then the auto-linking feature seems to select a dynamic library, and I want it all linked statically in one executable.

The same happens with the regex library: I have the same 4 regex libraries compiled and a quick test shows this linking error:

1>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_43.lib'

What to do?


Solution

  • The problem is fixed, during the compilation of the boost libraries, I selected the link=static option. Which creates static libraries. I also selected runtime-link=static option, and this was wrong!

    The solution for this problem was compiling boost with runtime-link=shared. Now some extra libraries are added, with the correct filenames, so the linker can find them. At first the compiler still searches for the dll library (boost_python-vc90-mt-gd-1_43.lib, instead of libboost_python-vc90-mt-gd-1_43.lib), everything else from boost links automatically to a static library, but because boost.python has a different auto-linkage set up, when you provide BOOST_PYTHON_STATIC_LIB, it finally links to the right library and it works!