Boost C++ Library
Guidance last updated: 18 October 2026
Boost provides free, peer-reviewed and portable C++ source libraries.
Usage
After connecting to Stanage (see Establishing a SSH connection), start an interactive session:
salloc
To activate the library run one of the following:
module load Boost/1.88.0-GCC-14.3.0
module load Boost/1.88.0-GCC-14.2.0
module load Boost/1.88.0-intel-compilers-2025.2.0
module load Boost/1.85.0-GCC-13.3.0
module load Boost/1.83.0-GCC-13.2.0
module load Boost/1.82.0-GCC-12.3.0
module load Boost/1.81.0-GCC-12.2.0
module load Boost/1.88.0-GCC-14.3.0
module load Boost/1.88.0-GCC-14.2.0
module load Boost/1.83.0-GCC-13.2.0
module load Boost/1.81.0-GCC-12.2.0
Boost has been built without Python support: use Conda and install the boost conda package if you want to use Boost with Python.
Build a simple program using Boost
Boost.Lambda is a header-only library, so this example does not need to link
against a separately compiled Boost library.
The following program reads a sequence of integers from standard input, uses Boost.Lambda to multiply each number by three, and writes them to standard output (taken from https://www.boost.org/doc/libs/1_88_0/more/getting_started/unix-variants.html):
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
Copy this into a file called example1.cpp and compile with:
g++ example1.cpp -o example
Provided you loaded the correct modules given above, the program should compile without error.
Run it with example input:
printf '1 2 3\n' | ./example
This prints 3 6 9.
Linking to a Boost library
The following program is taken from the official Boost documentation https://www.boost.org/doc/libs/1_88_0/more/getting_started/unix-variants.html
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[2] << std::endl;
}
}
This program makes use of the Boost.Regex library, which has a separately-compiled binary component we need to link to.
Assuming that the above program is called example2.cpp, compile with the following command:
g++ example2.cpp -o example2 -lboost_regex
Run it with an example email subject:
printf 'Subject: Re: Example\n' | ./example2
This prints Example.
Installation notes
Boost was installed using Easybuild, build details can be found in $EBROOTBOOST/easybuild with a given module loaded.