PrevUpHomeNext

Build and Install B2 Build


Jump in this page:
Start
Build & Install b2 build
Configure /etc/site-config.jam
Use default c++ compiler
Set version & path of compiler

Back: c++ Build System

Install B2 Build Toolchain.

B2 is an excellent c++ project build system.

B2 Build can be built and installed on windows, haiku, linux, bsd etc.

Build & Install b2 build

$ git clone --depth=1 https://github.com/bfgroup/b2
$ cd b2
$ ./bootstrap.sh
$ su
# ./b2 install --prefix=/sand

b2 build is installed to /sand, b2 binary file is installed as /sand/bin/b2 , make sure the path is added to the system environment variable PATH .

As windows user, you have to use a different path style for --prefix=path/to, figure out it by youself.

As haiku user, you have to set a permission-allowed path for --prefix=path/to, such as --prefix=/boot/home/sand

Configure /etc/site-config.jam

/etc/site-config.jam is the system-wide config file for b2,

if you have no permission to write /etc/site-config.jam,
you can write content to user-config.jam,
which is placed at your user home folder.

Use default c++ compiler

Use gcc, clang or msvc as the default c++ compiler.

To /etc/site-config.jam :

using gcc ;
using clang ;
using msvc ;

In such a configure, the g++, clang++, and cl.exe must all exist on the systems, if any one of them does not exist, do not add that line. Such as cl.exe does not exist on linux, remove "using msvc ;" .

The first c++ toolchain: "using gcc" in /etc/site-config.jam will be chose as the default c++ compiler when invoking b2 command:

$ b2

It will use g++ to build your project.

Set the version and path of the compiler

For example:

To /etc/site-config.jam :

using gcc : latest : /sand/bin/g++-16 ;

The first parameter of using is the toolchain name, which is the brand name of the c++ compiler, that must be approved by b2 build system.

The second parameter of using is the version, which can be set to any number or letters freely.

The third parameter of using is the full path of the c++ compiler command.

Alternative choice example:

To /etc/site-config.jam :

# If dpcpp command can be found by auto-detect.
using clang : dpcpp1 : dpcpp ;

# If dpcpp command can not be found by auto-detect.
# using clang : dpcpp2 : /path/to/intel/dpcpp/compiler/command ;

By the way, two or more <c++_compiler_brand_name>-<version> should be not the same, otherwise it's syntax error.

Such as above:

clang-dpcpp1

clang-dpcpp2

Date

Date: 2024

Last Update: Sep 06, 2026

Back

Back: c++ Build System

Helpful

Spaceship 50 Years Alienated

Role

+

Powered by:
B2 Build | boost quickbook

+

Donate

+

@cppfx.xyz


















PrevUpHomeNext