How to build & install boost without sudo

Here’s how you can build & install boost without sudo, i.e. if you don’t have root permissions on the machine you’re working on. This guide is mostly written for Linux but probably works on other systems as well.

Download boost from the Boost download page. I’ve tested this with 1.86.0 but it should work with many versions, both older and newer.

I recommend to download the .tar.bz2 version, that is the first link on the download page:

Boost What to Download

tar xjvf boost_1_86_0.tar.bz2
cd boost_1_86_0
./bootstrap.sh
./b2 install --prefix=$HOME/usr

This will install to $HOME/usr, which is a common location for user-installed software. You can change this to any other location you prefer. When using $HOME/usr, the headers will be installed in ~/usr/include and the libraries in ~/usr/lib etc.