How to compile Boost on Windows 10 using Visual Studio

I am working on a new project that requires the regex Boost library. I was able to use the no-compile headers, but I need some of the binaries that need to be compiled. The documentation for building to compile in Visual Studio was not very helpful (resulting in a few errors) and I saw many people on the internet run into these same issues, but it took a lot of Google to get them, so I included the detailed steps below to help someone with the same problems.

I am running Windows 10 and Visual Studio 11 (2012) preview, but the steps should work for other versions as well.

Step 1 - Configure the Developer Command Prompt in Visual Studio

You will need this in order to compile binaries. VS Command Prompt Window (Ctrl + W, A) doesn't seem to work.

1. In VS , select "Tools" at the top, then select "External Tools" and enter the following:
    -Title: "VS2013 Native Tools-Command Prompt" (your choice)
    -Command: C:\Windows\System32\cmd.exe
    -Arguments: /k "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"  (make sure to use the correct path to your version of VS)
    -Initial Directory: Select as suits your needs (if you'll use boost a bunch, I'd select the folder where you dropped boost)
2. Click OK. Now you have command prompt access under the same "Tools" menu, where it will show up as a new option.

Source: https://stackoverflow.com/questions/21476588/where-is-developer-command-prompt-for-vs2013

      

Step 2 - Run Bootstrap.bat from VS Developer Command Prompt

1. Navigate to your Boost folder (mine is C:\Program Files\boost\boost_1_58_0)
2. Run `.\Bootstrap.bat` which results in the following error:

    > 'cl' is not recognized as an internal or external command"

    Cl.exe is is a tool that controls the Microsoft C and C++ compilers and linker.  This error is because cl.exe is not in your path environment variable; it isn't automatically added when you install VS. Check by running the following:
    -In PowerShell - `($env:path).replace(';',"`n")` (easy to read)
    -In cmd.exe - `echo %path%` (harder to read)  

 4. Add cl.exe to your path by adding its parent folder "C:\Program Files (x86)\Microsoft Visual Studio [your version]\VC\bin"
    -Hit Win+X -> System -> Advanced System Settings -> Environment Variables -> Select "Path" under System Variables (in bottom pane) -> Edit -> paste the following to the end: ";C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin" (don't forget the semicolon on the front)
    -Test by opening a new command prompt or PowerShell window and type `cl.exe -?`

      

Step 3 - Restart bootstrap with cl.exe in your path

You may be missing some environment variables for Visual Studio, resulting in the following error:

mspdb110.dll not found

1. Navigate to the Visual Studio path in your Visual Studio developer command prompt (for me it C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin) 
2. Run `.\vcvars32.bat` which automatically sets some variables for you, but there is no output -- lack of error means likely success

      

Step 4 - Compile the Boost Files

The .\Bootstrap.bat

Visual Studio Developer Command Prompt execution should now succeed and you can now use the binaries in your project!

+3


source to share





All Articles