Search code examples
c++boost-pythonprogrammers-notepad

VisualStudio 2015 linker looking for VS 2010 library


I am trying to compile a old VS2010 project in VS2015 with boost.python 1_67_0 from 1_53 and python 35.

Getting it compile was not too hard, just a few tweaks to include path and updating a couple of python 2 string handling to python 3.

But I am stuck on linking because the linker fails at:

LINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_67.lib'

Which really does not make sense because the library version should be vc140. In the library path there does exist libboost_python35-vc140-mt-gd-x32-1_67.lib and a few others libboost_python35-vc140* options.

Where is it getting the name 'boost_python-vc100-mt-gd-1_67.lib' from? (i.e. is this something I missed in the configuration?)


Solution

  • Under Visual Studio Boost uses boost/configure/auto_link.hpp to generate the library names and add them to the linker's dependencies. One of the arguments to this bit of code is BOOST_LIB_NAME which for boost::python is defined in boost/python/detail/config.hpp. In version 1_67_0 this is currently:

    #define BOOST_LIB_NAME boost_python##PY_MAJOR_VERSION##PY_MINOR_VERSION

    Where the python patchlevel.h has the definitions for PY_MAJOR_VERSION and PY_MINOR_VERSION.

    This means that the library name itself does not need to explicitly added to the your Visual Studio project. Just the path to the boost libraries directory.

    For me I needed to remove any (boost) library names from:

    • Configuration Properties > Linker > Input > Additional Dependencies
    • Configuration Properties > Linker > All Options > Additional Dependencies

    And needed to ensure that I built boost::python with the shared (dll) libraries since I would building a DLL. The static libraries are libboost*.lib and the shared libraries are boost*.lib. To force the generation of the shared libraries I used:

    C:\dev\boost\boost_1_67_0> b2.exe link=shared,static --with-python -a