0

I'm aware that the new toolset is not supported by boost yet but I'd like to try to build Boost with it anyways. I've naively tried using the Boost build system and the option toolset=msvc-12.0-ctp but it doesn't work. I'm confident that it is possible since Boost 1.55 officially supports Visual Studio 2013 (msvc-12.0) and there have only been few breaking changes between the two releases.

My motivation is that I need some features of the CTP so my own application will be compiled with the CTP version of the msvc compiler. I'm afraid that simply compiling Boost with the original 2013 compiler will cause binary incompatibilities between Boost and my own application. Stephen T. Lavavej himself doesn't guarantee binary compatibility:

-- any chance of reusing Boost Binaries built for MSVC 2013 in MSVC Nov 2013 CTP

Because this is compiler-only, you can probably get away with mixing-and-matching. I wouldn't recommend it, though.

Any thoughts on how to solve this? Thanks in advance.

Frederik Aalund
  • 1,324
  • 2
  • 14
  • 17

1 Answers1

4

Note, that I did not built Boost with Visual Studio 2013 November CTP, so further explanations are purely theoretical.

After some Googling and trying, finally, I did it. So, algorithm is:

  1. Check out latest Boost from subversion (probably, it can be done with release distro, but I did not tried)

    svn co  http://svn.boost.org/svn/boost/trunk boost-trunk 
    
  2. Specify custom path to compiler in user-config.jam file, which is situated in %BOOST_HOME%/tools/build/v2/ (where %BOOST_HOME% is a path where you checked out your distro):

    • Add line like this:

    using msvc : 12.1 : "C:/Program Files (x86)/Microsoft Visual C++ Compiler Nov 2013 CTP/bin/cl" ;

    • you can use arbitrary string instead of 12.1, just put something here to distinguish your toolset later, when invoking b2

    • Don't forget to put spaces before and after colon and before semicolon, and also use slashes / or double backslashes \\ instead of backslashes \. See explanation in comments of user-config.jam file

    • Make sure that you don't have # in the beginning of the line (i.e. it is not commented)

  3. Run VS2013 x86 Native Tools Command prompt or run manually cmd.exe and then set up environment by invoking "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" -x86. Change x86 to x64 if needed.

  4. Add path to CTP compiler to PATH variable :

    set PATH=C:/Program Files (x86)/Microsoft Visual C++ Compiler Nov 2013 CTP/bin;%PATH%
    
  5. Check that path to CTP compiler goes before path to release one:

    echo %PATH%
    
  6. Go to %BOOST_HOME% and run b2 toolset=msvc-12.1 ...<other params go there>...

  7. In process manager or ProcessExplorer check that b2 invokes CTP compiler, and not release one

  8. Unfortunately, not all libraries builds fine. There are some compile errors.

See also:

Hope it helps. Happy building! =)

Community
  • 1
  • 1
Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • 1
    An excellent answer. Cheers! I got Boost to compile with the November 2013 CTP. I wanted x64 output which led to the following small change in step 2: `"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64`. Note that I use the option `x86_amd64` and not simply `-x64`. Firstly, it didn't work with the prefixed dash. Secondly, the compiler `cl.exe` is an x86 application so the variables must be set accordingly. The option `x86_amd64` chooses the x86 compiler and instructs it to cross-compile to x64 [[source](http://msdn.microsoft.com/en-us/library/x4d2c09s.aspx)]. – Frederik Aalund Jan 25 '14 at 11:58
  • Glad it was helpful. I think it's easier to control output platform by `address-model=` parameter to `b2`. Having path to `Visual Studio 12.0\VC\` it does all stuff automatically somehow, so no need for special set-up for different compiler environments. – Ivan Aksamentov - Drop Jan 25 '14 at 12:15
  • @FrederikAalund I was unable to build some libraries (notably locale, log, random, unit_test, etc.). If you'll succeed with building them, could you, please post your solution on SO as a self-answered question? – Ivan Aksamentov - Drop Jan 25 '14 at 12:23
  • 1
    Ah, I didn't know that the `address-model=64` option override the variables set using `vcvarsall.bat`. I also set `address-model=64` when I invoked `b2` just be sure. The Boost libraries locale, log, random, and unit_test all compiled for me using your guide. The only library that didn't compile was the graph library. I thought that library was header-only anyhow so I was surprised to find that it also had source files. I invoked `b2` like this: `b2 toolset=msvc-12.1 link=static threading=multi runtime-link=static address-model=64`. Maybe your errors are linkage related. – Frederik Aalund Jan 25 '14 at 12:36
  • 1
    Also, when linking against boost make sure that you have disabled automatic linking. The latter incorrectly tries to load the vc12.0 libraries and **not** the vc12.1 libraries. Automatic linking is disabled by defining `BOOST_ALL_NO_LIB` ([Source 1](http://stackoverflow.com/a/6646746/554283), [Source 2](http://stackoverflow.com/a/20025189/554283)). – Frederik Aalund Jan 25 '14 at 15:20