Install B2 Build Toolchain

Install B2 Build Toolchain - Utxcpp Official Docs

B2 is an excellent c++ project build system.

Build and install b2 build

Clone b2 code from github

$ git clone --depth=1

Build b2

$ cd b2
$ ./

Install b2

$ 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 .

Configure /etc/site-config.jam

/etc/site-config.jam is the system-wide config file for b2, the configure can be set to user config file ~/user-config.jam too.

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 exist on the systems, if any one of them does not exist, do not put 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 toolchain

For example:

To /etc/site-config.jam :

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

The first paramter 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 paramter 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 : dpcpp : dpcpp ;

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

By the way, <c++_compiler_brand_name>-<version> should not repeat, otherwise it's a syntax error.

See Also

Install Boost Doc Toolchain

B2 Build Home

B2 Manual

Utxcpp c++ docs

Last revised: February 24, 2024 at 08:57:24 GMT