How install Boost on Ubuntu? [SOLVED]

Written By - Omer Cakmak


Boost is a set of libraries for the C++ programming language (includes 164 separate libraries as of version 1.76) that provides support for tasks and constructs such as linear algebra, pseudorandom number generation, multithreading, image manipulation, regular expressions, and unit testing. These libraries are licensed under the Boost Software License, which is designed to allow Boost to be used with both free and proprietary software projects.

In this article, we will install Boost on Ubuntu.

Installation is done in 2 ways: installing package from Ubuntu repositories and compiling from source code.


Method-1: Install From Repository

First the package list is updated:

foc@ubuntu22:~$ sudo apt update -y

Then the libboost-all-dev package is installed:

foc@ubuntu22:~$ sudo apt install libboost-all-dev -y

After installation the libraries are in the following directory:

foc@ubuntu22:~$ ls /usr/lib/x86_64-linux-gnu/libboost_*

Installation completed quickly and easily.


Method-2: Install From Source Code

The download link to download Boost is on the official website.


How install Boost on Ubuntu? [SOLVED]


The source code is published as tar.gz, 7z and zip. Right click on the format you want to download and copy the address.

How install Boost on Ubuntu? [SOLVED]

Download the source code by typing the link after the wget command:

foc@ubuntu22:~$ wget
--2022-12-24 08:19:16--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: [following]
--2022-12-24 08:19:17--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 140221178 (134M) [application/x-gzip]
Saving to: ‘boost_1_81_0.tar.gz’

boost_1_81_0.tar.gz                  100%[====================================================================>] 133.72M  1.71MB/s    in 85s     

2022-12-24 08:20:43 (1.58 MB/s) - ‘boost_1_81_0.tar.gz’ saved [140221178/140221178]

Extract the compressed file:

foc@ubuntu22:~$ tar xvf boost_1_81_0.tar.gz

Enter the Boots directory:

foc@ubuntu22:~$ cd boost_1_81_0/

In this step, the source code will be built. So install the build dependencies:

foc@ubuntu22:~$ sudo apt install build-essential g++ python3-dev autotools-dev libicu-dev libbz2-dev-y

Give "" a "prefix" and run:

foc@ubuntu22:~/boost_1_81_0$ sudo ./ --prefix=/usr/
Building B2 engine..

### Using 'gcc' toolset.

g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

###foc@ubuntu22:~/boost_1_81_0$ sudo ./ --prefix=/usr/

> g++ -x c++ -std=c++11 -O2 -s -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filesys.cpp filent.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp -o b2
Unicode/ICU support for Boost.Regex?... /usr
Backing up existing B2 configuration in project-config.jam.1
Generating B2 configuration in project-config.jam for gcc...

Bootstrapping is done. To build, run:

To generate header files, run:

    ./b2 headers

The configuration generated uses gcc to build by default. If that is
unintended either use the --with-toolset option or adjust configuration, by
editing 'project-config.jam'.

Further information:

   - Command line help:
     ./b2 --help
   - Getting started guide:
   - B2 documentation:

Then run b2:

foc@ubuntu22:~/boost_1_81_0$ ./b2
Performing configuration checks

- default address-model : 64-bit [1]
- default architecture : x86 [1]
Building the Boost C++ Libraries.
- compiler supports SSE2 : yes [2]
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
The following directory should be added to linker library paths:

Then install with b2:

foc@ubuntu22:~/boost_1_81_0$ sudo ./b2 install
Performing configuration checks

- default address-model : 64-bit (cached) [1]
- default architecture : x86 (cached) [1]
- compiler supports SSE2 : yes (cached) [2]
common.copy /usr/lib/cmake/Boost-1.81.0/BoostConfig.cmake
common.copy /usr/lib/cmake/Boost-1.81.0/BoostConfigVersion.cmake
...updated 16003 targets...

After installation, the libraries are placed under the directory specified with "--prefix".

foc@ubuntu22:~$ ls /usr/lib/libboost_*

Boots installation completed successfully. You can use these libraries by adding them to your projects.



We installed the Boots libraries on Ubuntu with 2 different methods. We recommend installing from Ubuntu repositories. If you need to compile from source code for a different reason or need, the 2nd method will help for you.


References - How to install Boost on Ubuntu - Installation


Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment