How to install the Boost C++ libraries

Nov 30, 2019 | C++, Tutorials

The Boost C++ libraries are a set of free peer-reviewed C++ libraries. They are intended to be useful for a wide variety of applications and portable. Boost just makes life easier, here is how to install it on Linux.

Installing Boost using a package manager

The easiest way to install Boost is with your built-in package manager. It takes care of the installation of all of the dependencies and is more likely to be using a very stable version of the library. Also, there is the added benefit of it being easy to remove if you no longer want it.

Apt (Debian, Ubuntu, Pop OS, etc)

On most Debian based systems, you can install all of the Boost libraries with a single command.

apt-get install libboost-all-dev

DNF (Fedora, etc)

The newer versions of Fedora now use Dandified Yum, instead of just regular yum.

dnf install boost-devel

Yum (Centos, older versions of Fedora, etc)

yum install boost-devel

Manual Installation

If you require a different version of it than the one that is provided by your package manager, you can easily compile and install it manually.

Dependencies

Boost has very few dependencies. You mainly need just a C++ compiler and make.

  • C++ compiler (g++, clang++, etc)
  • make

Installation

With that out of the way, let’s get to the installation, do keep in mind that you will need to set the change the first few environment variables to what you would like them to be.

export MAJOR_VERSION=1
export MINOR_VERSION=70
export PATCH_VERSION=0
wget https://dl.bintray.com/boostorg/release/${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}/source/boost_${MAJOR_VERSION}_${MINOR_VERSION}_${PATCH_VERSION}.tar.gz
tar -xzf boost_${MAJOR_VERSION}_${MINOR_VERSION}_${PATCH_VERSION}.tar.gz
cd boost_${MAJOR_VERSION}_${MINOR_VERSION}_${PATCH_VERSION}
./bootstrap.sh
./b2 install -j$(nproc)

You should now have successfully installed Boost on your machine. For more details, I suggest taking a look at the official boost documentation

Testify; Test Your Go Code

Testify is a testing library that makes writing tests for your Go code easy. It reduces the amount of code you need for tests, while also providing extra functionality for easy mocking. Especially when combined with mockery, you really have a Golang testing...
mock

Mockery; Mock Everything In Go.

Mockery is an awesome tool that offers the ability to generate mocks from Go interfaces. Additionally, it's output uses the testify framework, so you can easily plug in your mocks and perform granular tests on your code. When combined with the power of a Makefile, it...