Learn the steps to install the Boost C++ libraries on Ubuntu 20.04 Focal Fossa or Ubuntu 22.04 Jammy JellyFish using the command terminal.
What are Boost C++ libraries?
The Boost C++ libraries are a collection of open-source C++ libraries that provide support for tasks and functionalities commonly used in C++ development. The Boost libraries are highly respected among C++ developers and are widely used in many applications and software projects.
The Boost libraries are designed to be portable, well-documented, and easy to use. They are distributed under the Boost Software License, which allows them to be used for both open-source and commercial projects. The Boost libraries cover a wide range of topics, including utilities, algorithms, data structures, and many others.
Some of the most popular Boost libraries include:
- Boost.Asio: A library for asynchronous I/O and networking
- Boost.Smart_pointers: A collection of smart pointer classes
- Boost.Thread: A library for threading and synchronization
- Boost.Regex: A regular expression library
- Boost.Spirit: A library for parsing and generation of text
- Boost.Bind: A library for creating function objects and bindings
To use the Boost libraries in your C++ project, you will need to download and install them on your system. Once they are installed, you can include the necessary headers in your C++ source files and use the classes and functions provided by the Boost libraries in your code.
Steps to install Boost on Ubuntu Linux
Although the steps are performed on Ubuntu 22.04, they can be used for older and newer versions of this Linux including Debian and other Linux based on it. Such as Linux Mint, POP OS, and more…
1. Update Ubuntu Linux
Here we are about to install the latest version of the Boost library, hence, we need to compile it from the source. Hence, make sure your system is up to date and the APT package manager has the latest package index cache.
sudo apt update && sudo apt upgrade
2. Install the Developer’s tool
We require tools to build the Boost library from its source code, here is the command to get the required libraries.
sudo apt-get install build-essential g++ python3-dev autotools-dev libicu-dev libbz2-dev libboost-all-dev
3. Download the Boost C++ library
The version of the Boost library available to install on Ubuntu Linux using the default system repository of Ubuntu is not the latest one. Therefore, we will download the latest version directly from its website.
Visit the Website and click on the Download button.

After that get the Tar file of the Boost library. For example:

Those who want to use the Command terminal to download the file can use the wget
command along with the URL of the file.
For that right-click on the Tar file and copy its address.
For example:
wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz
4. Extract the Tar file
Those who have used the browser to download the file, need to switch to the Downloads directory for that use cd Downloads
.
Whereas the Wget command users can find the downloaded in the same directory where they have run the command.
To extract use:
tar xvf boost_1_80_0.tar.gz
Note: Replace boost_1_80_0.tar.gz with your downloaded file version name.
5. Switch to the extracted directory
After extracting the files using the command given in the previous step, switch to the extracted directory using the cd command.
cd boost_1_80_0
Note: Replace boost_1_80_0 with your file name or version.
6. Setup Boost’s bootstrap
After that run the given command that will start the Bootstrap script present inside the Boost extracted folder. It will start building a B2 engine. Also, it will save the compiled library files under /usr/include/boost
./bootstrap.sh --prefix=/usr/

7. Install Boost on Ubuntu 20.04 or 22.04
Building the Boost C++ Libraries
Once you are done with building the b2 engine, you will see an executable file inside the Boost directory named b2. We have to run it to start building the Boost C++ libraries.
sudo ./b2 install
8. Use Boost library in C++ programming
Now, whenever you want to use or include the Boost library to start coding, you just need to include the name of the library of Boost you want to use.
For example, if you want to use an array library:
#include <iostream>
#include <boost/array.hpp>
using namespace std;
int main(){
boost::array<int, 4> arr = {{1,2,3,4}};
cout << "hi" << arr[0];
return 0;
}
Other Articles: