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/
Download the Boost libraries
- 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.
- Determine whether you will be building a 32-bit or 64-bit version of the Boost libraries.
- 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.
- Once the download is finished, run the installer as normal and note the installation directory.
Build the libraries for your machine
- Open the Developer Command Prompt for VS20xx under Start > Microsoft Visual Studio 20xx > Visual Studio Tools
- Once the Developer Command Prompt is open, type in cd <your Boost install directory>
- 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!
- 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.
Link the libraries through Visual Studio
- Open your C++ project in Visual Studio 20xx. Right click its name in the Solution Explorer and go to Properties.
- Click on Configuration Properties, then C/C++, and then All Options.
- Modify Additional Include Directories: append the “compiler include paths” string to the end of it.
- Click on Configuration Properties, then Linker, and then All Options.
- Modify Additional Library Directories: append the “linker library paths” string to the end of it.
- 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>
- Try to Rebuild your project. Hopefully, all of your library issues will now be resolved! Happy coding!
Parts of this write-up were figured out through Boost’s Visual Studio page.