Search code examples
visual-studioboostvisual-studio-2015visual-studio-2005

"Unknown compiler version" - Boost thinks VS2005 compiler is VS2015


So, I need to build projects in Visual Studio 2005 and Visual Studio 2015 on the same machine (64-but, win10). When switching back to a project built in 2005, Boost thinks I'm still using the 2017 compiler and throws all sorts of errors. Mainly this one: Unknown compiler version

My question: Does Visual Studio 2015 set something on my machine that boost would be looking at to determine the compiler version, or does boost store something? For the life of me, I can't figure out where boost is looking for this information.

I believe this is where boost is checking:

#if (_MSC_VER > 1600)
#  if defined(BOOST_ASSERT_CONFIG)
#     error "Unknown compiler version - please run the configure tests and     report the results"
#  else
#     pragma message("Unknown compiler version - please run the configure     tests and report the results")
#  endif
#endif

Where is _MSC_VER set?


Solution

  • To build the Boost.Build system for your version of Visual Studio, run the bootstrap.bat file in the corresponding Visual Studio command prompt.

    Boost.Build likes to default to higher versions of Visual Studio when it is compiling. When Boost.Build realizes that you have more than one version of Visual Studio installed, it will create environment variables like:

    VS140COMNTOOLS --> Visual Studio 2015

    VS80COMNTOOLS --> Visual Studio 2005

    You can switch from the VC++ 14.0 compiler to the VC++ 8 compiler by:

    1. Changing the name of the VC140COMNTOOLS environment variable - you can put an 'x' in front of it or add _DISABLED to it.
    2. Navigating to C:\Users{your user name}\AppData\Temp and deleting the auto-generated scripts "b2_msvc-8.0_{..blahblah..}.cmd" (there should be 2 - one for 32-bit builds and one for 64-bit builds). Although the name seems to be correct, don't be fooled - this file is not generated often and defaults to the newest version of Visual Studio on your machine.

    Once you have done both these steps, your compiler will regenerate the compilation scripts properly and should work.