Categories: Ubuntu

How to Install the Boost C++ on Ubuntu 22.04

As a C++ developer, having all the necessary tools to facilitate development is an added advantage. The Boost C++ library contains all the open-source libraries that you require for your C++ development. These libraries come bundled with Boost C++. Once you install it, you can start using the libraries in your code during development.

We will cover the complete installation of Boost C++ on Ubuntu 22.04.

Two Ways of Installing the Boost C++ on Ubuntu 22.04

You have two options to install the Boost C++ library on Ubuntu 22.04. First, you can install it via the Ubuntu apt repository, but that won’t give you the latest release. Alternatively, you can install it from its source code which gives you an access to the latest release.

1. Install the Boost C++ via APT

Installing it via the apt repository is the most convenient approach for a quick installation of Boost C++ on your Ubuntu 22.04. Start by updating the repository.

$ sudo apt update

The next step is installing the libboost-all-dev package which contains the Boost C++ development libraries.

$ sudo apt install libboost-all-dev

The Boost C++ packages are large in size. Press y to confirm the installation. Ensure an adequate space on your system to accommodate the installation.

Once the package completes the installation, verify that the installation is successful by checking the install Boost C++ version.

$ dpkg -s libboost-dev | grep version

The installed version is 1.74, but that’s not the latest release. To get the latest release, use the second installation method which we will discuss later in this article.

When you install the Boost C++ via APT, you can uninstall the installed package and the dependencies with the following command:

$ sudo apt autoremove libboost-all-dev

2. Install the Boost C++ via Source Code

For someone who are looking to get their hands dirty by installing the latest Boost C++ libraries, you must install them via its source code.

Start by visiting the Boost C++ website and open the “Downloads” section. Locate the option for the “Boost Downloads” and click on the “Current Release”.

A list of available current releases that you can download will appear. Right-click on the “tar.gz” option and copy its link. You can also click on it to start the download.

On your terminal, use wget to download the file via the terminal. Use the link that you copied with the wget command to initiate the download.

Once the download completes, navigate to the download directory. Here, we move the file to our “Downloads” to verify that we downloaded the tar file which contains the source code.

Extract the archive file with the following command:

$ tar xvf boost_1_81_0_tar.gz

Navigate into the extracted “Boots” directory.

$ cd boost_1_81_0/

We must install the required dependencies to support the installation of the Boost C++. Run the following command and all the dependencies will install:

$ sudo apt install build-essential python3-dev g++ autotools-dev libicu-dev libbz2-dev -y

We then need to set up the Boost’s bootstrap. The following command starts the Bootstrap script and builds the B2 engine:

$ sudo ./bootstrap.sh –prefix=/usr/

You can now run the generated B2 engine.

$ ./b2

Lastly, install the Boost C++ using the B2.

$ sudo ./b2 install

Once the program runs, the installation will complete, and you will have the Boost C++ libraries available on your system. You can then invoke them when writing your C++ projects.

Conclusion

The Boost C++ is a handy library to work with C++ projects. It offers different libraries that you can use. We covered two ways of installing it on your Ubuntu 22.04. You can directly install it via APT or using its source code. Use the method that is convenient for your case.

Ubuntu Server Admin

Recent Posts

How to avoid package End of Life through backporting

In July 2025, git received CVE-2025-48384, a high vulnerability allowing arbitrary code execution when cloning…

3 days ago

Showcasing open design in action: Loughborough University design students explore open source projects

Last year, we collaborated with two design student teams from Loughborough University in the UK.…

1 week ago

Canonical Ubuntu and Ubuntu Pro now available on AWS European Sovereign Cloud

January 15, 2026 – Canonical, the publisher of Ubuntu and provider of open source security,…

1 week ago

How to install GitLab on Ubuntu 24.04

How to install GitLab on Ubuntu 24.04 will be explained in this blog post with…

1 week ago

How to Set Up OpenVPN Access Server on Ubuntu 24.04 (VM) & Connect Using OpenVPN Connect

Do you know what was always there but has increased multiple times in the last…

2 weeks ago

How to build DORA-ready infrastructure with verifiable provenance and reliable support

The Digital Operational Resilience Act (DORA) came into force across the EU on January 17,…

2 weeks ago