Compiling boost1.47 on Windows7 64bit with VC2013 x64
I needed to compile boost1.47 in windows for win_ros so i decided to document what i did.
I tried different versions of boost but winros seems to only play nice with this one. If someone manages to compile winros with later version of boost that would be awesome and i’d like to know about it. But since we’re stuck with this boost version we need change a few things for it to compile under VC2013. Out of the box 1.47 doesn’t know about compilers later than VC2010, so we’ll teach it.
- In "boost1470\boost\signals\detail\namedslotmap.hpp" and "boost1470\libs\signals\src\namedslotmap.cpp" change BOOSTWORKAROUND(MSCVER, <= 1600) to BOOSTWORKAROUND(MSCVER, <= 1900)
- Run bootstrap.bat
- Now we need to modify some build files. All i did was to get the latest version of boost and copy the parts of of these files that deal with specifying settings for the latest compilers. So in "boost147_0\tools\build\v2\engine\build.bat"
replace
if NOT "_%VS100COMNTOOLS%_" == "__" (
with
call :ClearError if NOT "%VS140COMNTOOLS%" == "" ( set "BOOSTJAMTOOLSET=vc14" set "BOOSTJAMTOOLSETROOT=%VS140COMNTOOLS%....\VC\" goto :eof) call :ClearError if EXIST "%ProgramFiles%\Microsoft Visual Studio 14.0\VC\VCVARSALL.BAT" ( set "BOOSTJAMTOOLSET=vc14" set "BOOSTJAMTOOLSETROOT=%ProgramFiles%\Microsoft Visual Studio 14.0\VC\" goto :eof) call :ClearError if NOT "%VS120COMNTOOLS%" == "" ( set "BOOSTJAMTOOLSET=vc12" set "BOOSTJAMTOOLSETROOT=%VS120COMNTOOLS%....\VC\" goto :eof) call :ClearError if EXIST "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\VCVARSALL.BAT" ( set "BOOSTJAMTOOLSET=vc12" set "BOOSTJAMTOOLSETROOT=%ProgramFiles%\Microsoft Visual Studio 12.0\VC\" goto :eof) call :ClearError if NOT "%VS110COMNTOOLS%" == "" ( set "BOOSTJAMTOOLSET=vc11" set "BOOSTJAMTOOLSETROOT=%VS110COMNTOOLS%....\VC\" goto :eof) call :ClearError if EXIST "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\VCVARSALL.BAT" ( set "BOOSTJAMTOOLSET=vc11" set "BOOSTJAMTOOLSETROOT=%ProgramFiles%\Microsoft Visual Studio 11.0\VC\" goto :eof) call :ClearError if NOT "%VS100COMNTOOLS%" == "" (
and later in the same file replace:SkipVC10
with:SkipVC10 if NOT "%BOOSTJAMTOOLSET%" == "vc11" goto SkipVC11 if NOT "%VS110COMNTOOLS%" == "" ( set "BOOSTJAMTOOLSETROOT=%VS110COMNTOOLS%....\VC\" ) if "%VCINSTALLDIR%_" == "" call :CallIfExists "%BOOSTJAMTOOLSETROOT%VCVARSALL.BAT" %BOOSTJAMARGS% if NOT "%BOOSTJAMTOOLSETROOT%" == "" ( if "%VCINSTALLDIR%" == "" ( set "PATH=%BOOSTJAMTOOLSETROOT%bin;%PATH%" ) ) set "BOOSTJAMCC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib" set "BOOSTJAMOPTJAM=/Febootstrap\jam0" set "BOOSTJAMOPTMKJAMBASE=/Febootstrap\mkjambase0" set "BOOSTJAMOPTYYACC=/Febootstrap\yyacc0" set "known=1" :SkipVC11 if NOT "%BOOSTJAMTOOLSET%" == "vc12" goto SkipVC12 if NOT "%VS120COMNTOOLS%" == "" ( set "BOOSTJAMTOOLSETROOT=%VS120COMNTOOLS%....\VC\" ) if "%VCINSTALLDIR%_" == "" call :CallIfExists "%BOOSTJAMTOOLSETROOT%VCVARSALL.BAT" %BOOSTJAMARGS% if NOT "%BOOSTJAMTOOLSETROOT%" == "" ( if "%VCINSTALLDIR%" == "" ( set "PATH=%BOOSTJAMTOOLSETROOT%bin;%PATH%" ) ) set "BOOSTJAMCC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib" set "BOOSTJAMOPTJAM=/Febootstrap\jam0" set "BOOSTJAMOPTMKJAMBASE=/Febootstrap\mkjambase0" set "BOOSTJAMOPTYYACC=/Febootstrap\yyacc0" set "known=1" :SkipVC12 if NOT "%BOOSTJAMTOOLSET%" == "vc14" goto SkipVC14 if NOT "%VS140COMNTOOLS%" == "" ( set "BOOSTJAMTOOLSETROOT=%VS140COMNTOOLS%....\VC\" ) if "%VCINSTALLDIR%_" == "" call :CallIfExists "%BOOSTJAMTOOLSETROOT%VCVARSALL.BAT" %BOOSTJAMARGS% if NOT "%BOOSTJAMTOOLSETROOT%" == "" ( if "%VCINSTALLDIR%" == "" ( set "PATH=%BOOSTJAMTOOLSETROOT%bin;%PATH%" ) ) set "BOOSTJAMCC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib" set "BOOSTJAMOPTJAM=/Febootstrap\jam0" set "BOOSTJAMOPTMKJAMBASE=/Febootstrap\mkjambase0" set "BOOSTJAMOPTYYACC=/Febootstrap\yyacc0" set "known=1" :Skip_VC14
- Now in "boost147_0\tools\build\v2\engine\build.jam" replace
## Microsoft Visual C++ 2010 toolset vc10 cl : /Fe /Fe /Fd /Fo : -D : /nologo [ opt --release : /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
with
Microsoft Visual C++ 2010
toolset vc10 cl : /Fe /Fe /Fd /Fo : -D : /nologo [ opt --release : /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
Microsoft Visual C++ 2012
toolset vc11 cl : /Fe /Fe /Fd /Fo : -D : /nologo [ opt --release : /GL /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
Microsoft Visual C++ 2013
toolset vc12 cl : /Fe /Fe /Fd /Fo : -D : /nologo [ opt --release : /GL /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; toolset vc14 cl : /Fe /Fe /Fd /Fo : -D : /nologo [ opt --release : /GL /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
- Last touch. We need to change one source file so the the compilation won't throw warnings about unknown compiler. Take a look at "boost\config\compiler\visualc.hpp" in the newer version of boost and incorporate options related to the new compilers.
- And now comes the hack. I have VS2010 and VS2013 installed on the same machine and when i tired to compile boost it would grab vc10 compiler instead of vc12 like i wanted. So instead of getting to the bottom of it and doing it the right way i simply renamed my VS2010 folder for the time of the compilation and that seemed to do the trick. If someone knows how to make boost grab the right compiler please let me know. (specifying the compiler in the command line didn't help)
- And finally compile boost with this command:
b2 -d+2 --prefix=C:\boost --build-type=complete --build-dir=C:\boost\build --layout=tagged threading=multi variant=release address-model=64 link=shared
Asked by Eugene Simine on 2014-10-28 12:18:29 UTC
Comments
Hi Eugene, thank you very much for your guide: it is really helpful. BTW, have you tried to compile win_ros with newer versions of Boost? Are you getting the following error in that case? rospack.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::filesys
Asked by Atlancer on 2016-03-23 03:15:14 UTC
I was finally able to compile win_ros with Boost 1.56. The steps are described here: http://answers.ros.org/question/229926/winros_make-with-boost-156-and-vs2013-x64/?answer=230109#post-id-230109
Asked by Atlancer on 2016-03-24 22:07:11 UTC