Boost compiling with MSVC 11 (VS 2012)
I managed to get it to build by following these steps:
- Open a Visual Studio command prompt. From the start menu it's: All Programs|Microsoft Visual Studio 11|Native x64 Command Prompt.
- Unzip boost_1_48_0.zip and set the working directory to boost_1_48_0
- run bootstrap.bat
- run bjam.exe
It does generate a lot of warnings about not being able to detect the toolkit version, but it proceeds anyway.
Update: I created GitHub repo called cclibs which makes it simpler to build Boost and some other C++ libraries.
This answer works beautifully for:
VS2012
(Visual Studio 2012 Update 2)- or
VS2015
(Visual Studio 2015 Update 2)
- or
- Windows 7 x64
- or Windows 10 x64
- Boost v1.53
- or Boost v1.60
In a nutshell
- Open a Visual Studio 2012 command prompt. From the start menu its:
All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt
. - Unzip
boost_1_53_0.zip
toC:\boost153
. - run
bootstrap.bat
- run
bjam.exe
- In any new C++ project, include the path to the Boost libraries, as per the screenshot below.
(optional) Step-by-Step Instructions
- Install Visual Studio 2012.
- Install Update 2.
- Download Boost from SourceForge.
- Unzip into "C:\boost153"
- Open a Visual Studio Command prompt with Administrator privileges. From the start menu, its
All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt
. - Change to the boost directory with
cd c:\boost153
. - Run
bootstrap.bat
. - Run
bjam.exe
. This builds all of the libraries. - There may be some warnings, but you can ignore these.
When it has finished compiling after about 5 minutes, it states:
The Boost C++ Libraries were successfully built! The following directory should be added to compiler include paths: C:/boost153 The following directory should be added to linker library paths: C:\boost153\stage\lib
This is important, we will need to add these two paths to any new C++ project.
- Create a new C++ project.
- As noted a couple of steps ago, add
C:/boost153
to thecompiler include path
andC:\boost153\stage\lib
to thelinker library path
. - Right click on the project, select
Properties
, selectConfiguration Properties..VC++ Directories
. See the two portions of bolded text in the screenshot below): Let's run a simple program that shows off the power of boost, by adding support for
foreach
loops:// Source code below copied from: // http://www.boost.org/doc/libs/1_53_0/doc/html/foreach.html #include "stdafx.h" #include <string> #include <iostream> #include <conio.h> // Supports _getch() #include <boost/foreach.hpp> int main() { std::string hello( "Hello, world!" ); BOOST_FOREACH( char ch, hello ) { std::cout << ch; } _getch(); return 0; }
Result:
Hello, world!
More Answers
- See Boost compiling with MSVC 11 (VS 2012).
- See Official Boost docs on compiling with Visual Studio under Windows.
- See Building Boost v1.64.
Update 2016-05-05
Checked with Win10 x64
+ VS2015.2
+ Boost v1.6.0
.
bootstrap.bat
bjam.exe --toolset=msvc-11
Check that your installation is correct by confirming the output of the following command:
C:\>echo %VS110COMNTOOLS%
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
Here's some simple instructions to follow to get rid of warnings when bootstrapping: http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html
Don't miss his follow-up post that deals with the automatic linking.