Configuring C++ Boost Libraries for Visual Studio

Summary

Here is a basic guide to getting C++ Boost libraries to work within Visual Studio.

More information about these handy libraries is available here: http://www.boost.org/

 

Installation

 

Download the Boost libraries

  1.  Determine the version of Visual Studio that you will be using for your project. For example, Visual Studio C++ 2012 is also known as version 11. You can find this out by clicking HELP > About Visual Studio and looking for the “Version ##” line on the screen.
  2. Determine whether you will be building a 32-bit or 64-bit version of the Boost libraries.
  3. Now that you have determined these two pieces of information, navigate to http://sourceforge.net/projects/boost/files/boost-binaries/, click on the folder for the latest version, and download the correct .exe installer for your Visual Studio version and architecture.
  4. Once the download is finished, run the installer as normal and note the installation directory.

Build the libraries for your machine

  1. Open the Developer Command Prompt for VS20xx under Start > Microsoft Visual Studio 20xx > Visual Studio Tools

    vs_dev

    The location of the Developer Command Prompt for VS2012.

  2. Once the Developer Command Prompt is open, type in cd <your Boost install directory>
  3. Next, type these commands to build the Boost libraries for your machine: bootstrap and then b2. This last command will run for about ten minutes, so take a break!
  4. Once b2 has finished, you should see it print two lines noting “compiler include paths” and “linker library paths”. Write these paths down or take a screenshot.
boost

The Boost build has finished, and Boost tells us where to find the new libraries.

Link the libraries through Visual Studio

  1. Open your C++ project in Visual Studio 20xx. Right click its name in the Solution Explorer and go to Properties.
  2. Click on Configuration Properties, then C/C++, and then All Options.
  3. Modify Additional Include Directories: append the “compiler include paths” string to the end of it.
  4. Click on Configuration Properties, then Linker, and then All Options.
  5. Modify Additional Library Directories: append the “linker library paths” string to the end of it.
  6. Click OK to save your changes. Ensure that you are including the specific Boost libraries like this at the top of your source files: #include <boost/foreach.hpp>
  7. Try to Rebuild your project. Hopefully, all of your library issues will now be resolved! Happy coding!

 

Other Resources

Parts of this write-up were figured out through Boost’s Visual Studio page.

Advertisements

2 thoughts on “Configuring C++ Boost Libraries for Visual Studio

  1. Pingback: Configuring Apache Thrift for Visual Studio 2012 | Elektron Nine

  2. Pingback: Apache Thrift и C++ для Visual Studio 2013 (2015) на Windows — Разработка программ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s