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.
$ 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
/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 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.
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: 2024
Last Update: Sep 06, 2026
Back: c++ Build System
+
Powered by:
B2 Build
| boost quickbook
+
+