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

How-to: Set up Eclipse Subversive to work with Maven Projects

Last week, I configured Eclipse to check out Maven projects properly with the Subversive SVN plugin. This plugin will allow you to directly check in/out Maven code from your SVN into Eclipse, which will save you a lot of time.

Setting up Plugins

Here are nine steps for setting everything up properly. Note that if you simply want to install Subversive and do not care for the Maven integration, you can stop after Step 6:

  1. Open Eclipse and click Help > Eclipse Marketplace

    eclipsemarketplace

    Help > Eclipse Marketplace menu

  2. Search the Marketplace for “Subversive” and choose to Install Subversive – SVN Team Provider 1.1.2
  3. Restart Eclipse once this installation has finished.
  4. When Eclipse starts again, install the SVN connectors for Subversive. Go to Help > Install New Software and enter http://community.polarion.com/projects/subversive/download/eclipse/3.0/juno-site/ into the “Work with:” field
  5. Place a checkmark next to: Subversive SVN Connectors.  Feel free to install any other connectors you may need as well.
  6. Click Finish to install the SVN connector. This may require another restart of Eclipse.
  7. Next, install the Maven2Eclipse plugin: click Help > Eclipse Marketplace and search for Maven2Eclipse then install it, following steps 2 and 3 above for that plugin.
  8. Finally, install Subversive Maven Integration. Go to Help > Install New Software again and enter http://community.polarion.com/projects/subversive/download/integrations/update-site/ into the “Work with:” field
  9. Place a checkmark next to Subversive Integration for the M2Eclipse Project and click Finish to install it.

Checking out Maven Projects

Once you have all of this set up, you will be able to check code directly in and out of your SVN from within Eclipse, which is much more convenient than copying projects into Eclipse manually.

Click on Window > Open Perspective > Other > SVN Repository Exploring

eclipseopenperspective

Eclipse’s Open Perspective dialog.

There, you can right-click the Repositories window and add the web address for your SVN.
Checking out a project is easy – right click any SVN folder to Check Out as Maven Project and specify which pom.xml file to use.

This should save you a significant amount of time once you have configured it correctly! Happy coding!