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.
Anchor List:
$ 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 .
For windows users, you have to use a different path style for --prefix=path/to, figure it by youself.
For haiku users, you have to set a permssion-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 to user-config.jam, which have to place 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 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.
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.
Build and Install Boost Docs System
2024