Question

Is it possible to make automatic build of the current boost libraries with b2.exe tool for "v110_xp" platform toolset?

I looking for something like this:

set MSVC_TOOLSET=msvc-11.0_xp
set PLATFORM_TOOLSET=v110_xp

b2 --build-dir="..\32\%PLATFORM_TOOLSET%\build" toolset=%MSVC_TOOLSET% --stagedir="..\32\%PLATFORM_TOOLSET%\lib\Debug" variant=debug

It looks like there is currently no command line support for this scenario. Is it correct?

Was it helpful?

Solution 3

It looks like you can build Boost with the platform toolset v110 and use these in your application that you build with platform toolset v110_xp. See: vs2012 toolset compatibility

I still need to test this, though. Perhaps someone else has more experience with this.

OTHER TIPS

These instructions assume you have Visual Studio 2012 or Visual Studio 2012 Express edition installed along with boost 1.54.

Change the content of the below files in boost folder( which is downloaded and extracted)

In boost_1_54_0\tools\build\v2\tools change the following files:

1. msvc.jam

Change:

toolset.flags msvc LINKFLAGS <user-interface>console : /subsystem:console ;

to this for 32 bit:

toolset.flags msvc LINKFLAGS <user-interface>console : /subsystem:console,5.01 ;

or this for 64 bit:

toolset.flags msvc LINKFLAGS <user-interface>console : /subsystem:console,5.02 ;

2. msvc.py

Change:

toolset.flags('msvc', 'LINKFLAGS', ['<user-interface>console'], ['/subsystem:console'])

to this for 32 bit:

toolset.flags('msvc', 'LINKFLAGS', ['<user-interface>console'], ['/subsystem:console,5.01'])

or this for 64 bit:

toolset.flags('msvc', 'LINKFLAGS', ['<user-interface>console'], ['/subsystem:console,5.02'])

In boost_1_54_0\tools\build\v2\engine change the following files:

1. build.bat

Change:

if EXIST "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\VCVARSALL.BAT" (

to:

if EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\VCVARSALL.BAT" (

Above the line that reads :Skip_VC11, change:

set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"

to:

set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ /D _USING_V110_SDK71_ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"

Open a standard command prompt and type the following commands:

call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"

set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%

set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%

set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%

cd <path to boost_1_54_0>

bootstrap

For 32 bit, use the command:

b2 toolset=msvc-11.0 variant=debug,release link=shared runtime-link=shared address-model=32

or for 64 bit:

b2 toolset=msvc-11.0 variant=debug,release link=shared runtime-link=shared address-model=64

To compile any sample for release and debug versions, do the following:

Open a standard command prompt and type the following commands:

call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"

set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%

set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%

set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%

cd to the directory of the sample, ie boost_1_54_0\libs\test\tools\console_test_runner

<path to boost>\boost_1_54_0\bjam.exe --v2 toolset=msvc-11.0 variant=debug,release link=shared threading=multi runtime-link=shared

Answers from @Paul and @Kanchari worked well for me, until Boost 1.55 has come. After that I had to make additional tweaks. So I generalized @Kanchari answer to simple shell script, that works without Boost distrib modifications. Look for full script on GitHub, here is a steps for build manual from console (x86 version, MSVS default paths):

  1. Unpack boost and goto root folder in console
  2. According to MSDN:

    ::setup environment
    call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
    
    ::setup paths
    set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
    set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
    set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
    
    ::cl and linker settings
    set CL=/D_USING_V110_SDK71_ %CL%
    set LINK=/SUBSYSTEM:CONSOLE,5.01 %LINK%
    
  3. According to another MSDN set defines for Win XP. MSDN says what you may define WINVER or _WIN32_WINNT, but, just in case, i use both. Carefully with ^ here.

    set XP_TOOLSET_DEFINES=define=WINVER=0x0501 define=_WIN32_WINNT=0x0501 ^
    define=NTDDI_VERSION=0x05010000 define=PSAPI_VERSION=1
    
  4. Build Boost build system

    call bootstrap.bat
    
  5. Build Boost libraries with b2 and your project params. For example - debug multithread static libraries.

    b2 toolset=msvc-11.0 %XP_TOOLSET_DEFINES% ^
    variant=debug link=static threading=multi runtime-link=shared 
    

Important note:

In main project you must (in addition to set v110_xp toolset) also define WINVER or _WIN32_WINNT (by #define in .cpp, or /D compiler option)

If you are using the boost libraries on a Visaul C++ project, I believe that you do not need to recompile boost with the v110_xp toolset. You just have to make sure that when using the headers, your WINVER and _WIN32_WINNT are set to the correct versions. BOOST (1.57, at least) uses XP compatibility mode by default (and SDK 7.1 among other things) if you do not set these macros while compiling your projects.

This is also the case for VS 2013 and the v120_xp toolset. When we compiled our VC++ projects from VS 2013 with the v120_xp toolset which used many external libraries, boost among them, initially the executables did not run on Win XP. After digging around a lot, we found that the problem was not the newly compiled boost libraries (with msvc 12), but some other external library, which we had to recompile with v120_xp toolset. The boost libraries compiled with msvc 12 worked just fine (we used its autolinking feature)

Here is a link to boost's (1.56, but its the same in 1.57) windows config header that sets the xp compatibility mode.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top