Get Started With Boost in 3 Minutes

Boost is simply a collection of C++ libraries that provide lots of fun things to do in C++ without you having to write the code yourself.

For example, Boost contains libraries to help you with mathematical calculations, regular expressions, smart pointers and even python integration.

Parts of Boost have already been integrated into C++11, but if you (or your organisation) is not quite ready for C++11 yet, or you want to play with the other Boost libraries, you can get to grips with it really easily in just 3 minutes.

This guide covers the header only libraries (i.e. most of them). I’ll take a look at the compiled libraries next week.

1) Install Boost

As root/sudo type:

yum install boost-devel

You must install ‘boost-devel’, rather than just ‘boost’, or you will only get the compiled libraries and not the headers. Since boost is mostly header-only libraries, this won’t be much use!

Time taken: 30 seconds

2) Write yourself a program and Boost it!

In order to use the boost methods, you must include the namespace qualifier.

If you don’t, your compiler will tell you that the methods are undefined and you may end up on a wild goose chase trying to ensure that boost is installed correctly and that the header files are being found. Stop right there!

You can either include it in one line (as I have done here), or you can individually qualify each method you use, e.g. with boost::gregorian::.