Search code examples
c++boostlinker

boost linker error wrong toolset


there are many questions related to this but none so far is a solution in my case. I built boost 1.63 libraries with VS 2017, using toolset 14.1

The command line for building boost libs is:

bjam --toolset=msvc-14.1 --build-dir="libs"  --stagedir="x64" --build-type=complete stage  address-model=64 threading=multi link=static runtime-link=static

The 2nd lib in the build folder is

libboost_atomic-vc141-mt-sgd-1_63.lib

My project using boost is pointing to this folder. But linking with VS 2017 and Toolset 14.1 selected throws an error:

LINK : fatal error LNK1104: cannot open file 'libboost_atomic-vc140-mt-sgd-1_63.lib'

As you can see, only the toolset in incorrect. Is there an additional switch and where to find ? Thank you.

One comment: i built the bjam.exe with project-config.jam setting

using msvc : 14.1;

and libraries been built lightning fast: Below 20 seconds for all x64 libraries!


Solution

  • Boost 1.63 hasn't been made compatible with Visual Studio 2017, so there's a few things you gotta do manually to fix things. In order to make sure it picks up the correct library files, you need to make edits to auto_link.hpp, which is found in boost/config. Change these lines:

    # elif defined (BOOST_MSVC)
    
         // vc14:
    #  define BOOST_LIB_TOOLSET "vc140"
    

    To this:

    # elif defined (BOOST_MSVC) && (BOOST_MSVC < 1910)
    
         // vc14:
    #  define BOOST_LIB_TOOLSET "vc140"
    
    # elif defined (BOOST_MSVC)
    
         // vc15:
    #  define BOOST_LIB_TOOLSET "vc141"
    

    And then do a clean recompile of the boost libraries, and replace the original version of this file in your includes with this modified version.