Monday, 23 April 2012

Boost on Visual Studio 11

Boost 1.49 is full of references to VS11, although it is still not supported by default. Some tweaks I did:

tools\build\v2\engine\build.bat
The section :Guess_Toolset has to know that VS11 exists, add the following part:
call :Clear_Error
if NOT "_%VS110COMNTOOLS%_" == "__" (
    set "BOOST_JAM_TOOLSET=vc11"
    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
    goto :eof)
 Same goes for :Config_Toolset, add the following part:
:Skip_VC10
if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc11_" goto Skip_VC11
if NOT "_%VS110COMNTOOLS%_" == "__" (
    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
    )
if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
    if "_%VCINSTALLDIR%_" == "__" (
        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
        ) )
set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
rem change it back because VC11 is not officially known.
set "BOOST_JAM_TOOLSET=msvc"
set "_known_=1"
Credits for the part above: http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html

In my case, the build system was still using the compiler from the VS10 installation and I had to tweak some more.

Open the following file:
tools\build\v2\tools\msvc.jam

I basically searched the file for occurences of 10.0 and added equivalent entries for 11.0
credits: http://article.gmane.org/gmane.comp.lib.boost.devel/228596/

That should do it. Open up a Visual Studio command prompt and bootstrap the build system.
bootstrap.bat
Check for errors, and start the build process, in my case I executed the following command:
 b2 link=static threading=multi address-model=64

1 comment:

  1. For my own reference: right now everything is on its default values, compilation is done with two simple commands.
    bootstrap
    bjam -j 4 address-model=64

    ReplyDelete