Boost.Build comes with support for a large number of C++ compilers, and other tools. This section documents how to use those tools.
Before using any tool, you must declare your intention, and possibly
specify additional information about the tool's configuration. This is
done by calling the using
rule, typically in your
user-config.jam
, for example:
using gcc ;
additional parameters can be passed just like for other rules, for example:
using gcc : 4.0 : g++-4.0 ;
The options that can be passed to each tool are documented in the subsequent sections.
This section lists all Boost.Build modules that support C++
compilers and documents how each one can be initialized. The name
of support module for compiler is also the value for
the toolset
feature that can be used to explicitly
request that compiler.
The gcc
module supports the
GNU C++ compiler
on Linux, a number of Unix-like system including SunOS and on Windows
(either Cygwin or
MinGW). On Mac OSX, it is recommended
to use system gcc, see the section called “Apple Darwin gcc”.
The gcc
module is initialized using the following
syntax:
using gcc : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the version is not explicitly specified, it will be
automatically detected by running the compiler with the -v
option. If the command is not specified, the g++
binary will be searched in PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
root
Specifies root directory of the compiler installation. This option is necessary only if it is not possible to detect this information from the compiler command—for example if the specified compiler command is a user script.
archiver
Specifies the archiver command that is used to produce static libraries. Normally, it is autodetected using gcc -print-prog-name option or defaulted to ar, but in some cases you might want to override it, for example to explicitly use a system version instead of one included with gcc.
ranlib
Specifies the ranlib command that is used to generated symbol table for static libraries. Normally, it is autodetected using gcc -print-prog-name option or defaulted to ranlib, but in some cases you might want to override it, for example to explicitly use a system version instead of one included with gcc.
rc
Specifies the resource compiler command that will be used with the version of gcc that is being configured. This setting makes sense only for Windows and only if you plan to use resource files. By default windres will be used.
rc-type
Specifies the type of resource compiler. The value can
be either windres
for msvc resource compiler,
or rc
for borland's resource compiler.
address-model=64
, and the instruction-set
feature should refer to a 64 bit processor. Currently, those
include nocona
, opteron
,
athlon64
and athlon-fx
.
The darwin
module supports the version of gcc that is
modified and provided by Apple. The configuration is essentially identical
to that of the gcc module.
The darwin toolset can generate so called "fat"
binaries—binaries that can run support more than one
architecture, or address mode. To build a binary that can run both
on Intel and PowerPC processors, specify
architecture=combined
. To build a binary that can run
both in 32-bit and 64-bit modes, specify
address-model=32_64
. If you specify both of those
properties, a "4-way" fat binary will be generated.
The msvc
module supports the
Microsoft Visual
C++ command-line tools on Microsoft Windows. The supported
products and versions of command line tools are listed below:
Visual Studio 2017—14.1
Visual Studio 2015—14.0
Visual Studio 2013—12.0
Visual Studio 2012—11.0
Visual Studio 2010—10.0
Visual Studio 2008—9.0
Visual Studio 2005—8.0
Visual Studio .NET 2003—7.1
Visual Studio .NET—7.0
Visual Studio 6.0, Service Pack 5—6.5
The user would then call the boost build executable with the toolset set equal to msvc-[version number] for example to build with Visual Studio 2017 one could run:
.\b2 toolset=msvc-14.1 target
The msvc
module is initialized using the following
syntax:
using msvc : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the version is not explicitly specified, the most recent
version found in the registry will be used instead. If the special
value all
is passed as the version, all versions found in
the registry will be configured. If a version is specified, but the
command is not, the compiler binary will be searched in standard
installation paths for that version, followed by PATH
.
The compiler command should be specified using forward slashes, and quoted.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
assembler
The command that compiles assembler sources. If
not specified, ml will be used. The command
will be invoked after the setup script was executed and adjusted
the PATH
variable.
compiler
The command that compiles C and C++ sources. If
not specified, cl will be used. The command
will be invoked after the setup script was executed and adjusted
the PATH
variable.
compiler-filter
Command through which to pipe the output of running the compiler. For example to pass the output to STLfilt.
idl-compiler
The command that compiles Microsoft COM interface
definition files. If not specified, midl will
be used. The command will be invoked after the setup script was
executed and adjusted the PATH
variable.
linker
The command that links executables and dynamic
libraries. If not specified, link will be used.
The command will be invoked after the setup script was executed
and adjusted the PATH
variable.
mc-compiler
The command that compiles Microsoft message
catalog files. If not specified, mc will be
used. The command will be invoked after the setup script was
executed and adjusted the PATH
variable.
resource-compiler
The command that compiles resource files. If not
specified, rc will be used. The command will be
invoked after the setup script was executed and adjusted the
PATH
variable.
setup
The filename of the global environment setup script to run before invoking any of the tools defined in this toolset. Will not be used in case a target platform specific script has been explicitly specified for the current target platform. Used setup script will be passed the target platform identifier (x86, x86_amd64, x86_ia64, amd64 or ia64) as a parameter. If not specified a default script is chosen based on the used compiler binary, e.g. vcvars32.bat or vsvars32.bat.
setup-amd64
, setup-i386
, setup-ia64
The filename of the target platform specific environment setup script to run before invoking any of the tools defined in this toolset. If not specified the global environment setup script is used.
Starting with version 8.0, Microsoft Visual Studio can generate binaries for 64-bit processor, both 64-bit flavours of x86 (codenamed AMD64/EM64T), and Itanium (codenamed IA64). In addition, compilers that are itself run in 64-bit mode, for better performance, are provided. The complete list of compiler configurations are as follows (we abbreviate AMD64/EM64T to just AMD64):
32-bit x86 host, 32-bit x86 target
32-bit x86 host, 64-bit AMD64 target
32-bit x86 host, 64-bit IA64 target
64-bit AMD64 host, 64-bit AMD64 target
64-bit IA64 host, 64-bit IA64 target
The 32-bit host compilers can be always used, even on 64-bit Windows. On the contrary, 64-bit host compilers require both 64-bit host processor and 64-bit Windows, but can be faster. By default, only 32-bit host, 32-bit target compiler is installed, and additional compilers need to be installed explicitly.
To use 64-bit compilation you should:
Configure you compiler as usual. If you provide a path to the compiler explicitly, provide the path to the 32-bit compiler. If you try to specify the path to any of 64-bit compilers, configuration will not work.
When compiling, use address-model=64
,
to generate AMD64 code.
To generate IA64 code, use
architecture=ia64
The (AMD64 host, AMD64 target) compiler will be used automatically when you are generating AMD64 code and are running 64-bit Windows on AMD64. The (IA64 host, IA64 target) compiler will never be used, since nobody has an IA64 machine to test.
It is believed that AMD64 and EM64T targets are essentially
compatible. The compiler options /favor:AMD64
and
/favor:EM64T
, which are accepted only by AMD64
targeting compilers, cause the generated code to be tuned to a
specific flavor of 64-bit x86. Boost.Build will make use of those
options depending on the value of theinstruction-set
feature.
Starting with version 11.0, Microsoft Visual Studio can
produce binaries for Windows Store and Phone in addition to
traditional Win32 desktop. To specify which Windows API set
to target, use the windows-api
feature.
Available options are desktop
,
store
, or phone
. If not
specified, desktop
will be used.
When using store
or phone
the specified toolset determines what Windows version is
targeted. The following options are available:
Windows 8.0: toolset=msvc-11.0 windows-api=store
Windows 8.1: toolset=msvc-12.0 windows-api=store
Windows Phone 8.0: toolset=msvc-11.0 windows-api=phone
Windows Phone 8.1: toolset=msvc-12.0 windows-api=phone
For example use the following to build for Windows Store 8.1 with the ARM architecture:
.\b2 toolset=msvc-12.0 windows-api=store architecture=arm
Note that when targeting Windows Phone 8.1, version 12.0 didn't include the vcvars phone setup scripts. They can be separately downloaded from here.
The intel-linux
and intel-win
modules
support the Intel C++ command-line compiler—the Linux
and
Windows versions respectively.
The module is initialized using the following syntax:
using intel-linux : [version
] : [c++-compile-command
] : [compiler options
] ;
or
using intel-win : [version
] : [c++-compile-command
] : [compiler options
] ;
respectively.
This statement may be repeated several times, if you want to configure several versions of the compiler.
If compiler command is not specified, then Boost.Build will
look in PATH
for an executable icpc
(on Linux), or icc.exe (on Windows).
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
The Linux version supports the following additional options:
root
Specifies root directory of the compiler installation. This option is necessary only if it is not possible to detect this information from the compiler command—for example if the specified compiler command is a user script.
The acc
module supports the
HP aC++ compiler
for the HP-UX operating system.
The module is initialized using the following syntax:
using acc : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, the aCC
binary will be searched in PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
The borland
module supports the command line
C++ compiler included in
C++ Builder 2006
product and earlier version of it, running on Microsoft Windows.
The supported products are listed below. The version reported by the command lines tools is also listed for reference.:
C++ Builder 2006—5.8.2
CBuilderX—5.6.5, 5.6.4 (depending on release)
CBuilder6—5.6.4
Free command line tools—5.5.1
The module is initialized using the following syntax:
using borland : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named bcc32 in PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
The como-linux
and the como-win
modules supports the
Comeau C/C++ Compiler
on Linux and Windows respectively.
The module is initialized using the following syntax:
using como-linux : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named como in
PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
Before using the Windows version of the compiler, you need to
setup necessary environment variables per compiler's documentation. In
particular, the COMO_XXX_INCLUDE
variable should be
set, where XXX
corresponds to the used backend C
compiler.
The cw
module support CodeWarrior compiler,
originally produced by Metrowerks and presently developed by
Freescale. Boost.Build supports only the versions of the compiler that
target x86 processors. All such versions were released by Metrowerks
before acquisition and are not sold any longer. The last version known
to work is 9.4.
The module is initialized using the following syntax:
using cw : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for a
binary named mwcc in default installation paths and
in PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
root
Specifies root directory of the compiler installation. This option is necessary only if it is not possible to detect this information from the compiler command—for example if the specified compiler command is a user script.
setup
The command that sets up environment variables prior to invoking the compiler. If not specified, cwenv.bat alongside the compiler binary will be used.
compiler
The command that compiles C and C++ sources.
If not specified, mwcc will be used. The
command will be invoked after the setup script was
executed and adjusted the PATH
variable.
linker
The command that links executables and dynamic
libraries.
If not specified, mwld will be used. The
command will be invoked after the setup script was
executed and adjusted the PATH
variable.
The dmc
module supports the
Digital Mars C++ compiler.
The module is initialized using the following syntax:
using dmc : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named dmc in
PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
The hp_cxx
modules supports the
HP C++ Compiler for Tru64 Unix.
The module is initialized using the following syntax:
using hp_cxx : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named hp_cxx in PATH
.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
The sun
module supports the
Sun Studio C++ compilers for the Solaris OS.
The module is initialized using the following syntax:
using sun : [version
] : [c++-compile-command
] : [compiler options
] ;
This statement may be repeated several times, if you want to configure several versions of the compiler.
If the command is not specified, Boost.Build will search for
a binary named CC
in /opt/SUNWspro/bin
and in
PATH
.
When using this compiler on complex C++ code, such as the
Boost C++ library, it is
recommended to specify the following options when initializing the
sun
module:
-library=stlport4 -features=tmplife -features=tmplrefstatic
See the Sun C++ Frontend Tales for details.
The following options can be provided, using <
syntax:option-name
>option-value
cflags
Specifies additional compiler flags that will be used when compiling C sources.
cxxflags
Specifies additional compiler flags that will be used when compiling C++ sources.
compileflags
Specifies additional compiler flags that will be used when compiling both C and C++ sources.
linkflags
Specifies additional command line options that will be passed to the linker.
address-model=64
property.
The vacpp
module supports the
IBM Visual
Age C++ Compiler, for the AIX operating system. Versions
7.1 and 8.0 are known to work.
The module is initialized using the following syntax:
using vacpp ;
The module does not accept any initialization options. The
compiler should be installed in the /usr/vacpp/bin
directory.
Later versions of Visual Age are known as XL C/C++. They
were not tested with the the vacpp
module.
Boost.Build provides special support for some third-party C++ libraries, documented below.
The STLport library is an alternative implementation of C++ runtime library. Boost.Build supports using that library on Windows platform. Linux is hampered by different naming of libraries in each STLport version and is not officially supported.
Before using STLport, you need to configure it in
user-config.jam
using the following syntax:
using stlport : [version
] :header-path
: [library-path
] ;
Where version
is the version of
STLport, for example 5.1.4
,
headers
is the location where
STLport headers can be found, and libraries
is the location where STLport libraries can be found.
The version should always be provided, and the library path should
be provided if you're using STLport's implementation of
iostreams. Note that STLport 5.* always uses its own iostream
implementation, so the library path is required.
When STLport is configured, you can build with STLport by
requesting stdlib=stlport
on the command line.
Provides support for the zlib library. zlib can be configured either to use precompiled binaries or to build the library from source.
zlib can be initialized using the following syntax
using zlib : [version
] : [options
] : [condition
] : [is-default
] ;
Options for using a prebuilt library:
search
The directory containing the zlib binaries.
name
Overrides the default library name.
include
The directory containing the zlib headers.
If none of these options is specified, then the environmental variables ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will be used instead.
Options for building zlib from source:
source
The zlib source directory. Defaults to the environmental variable ZLIB_SOURCE.
tag
Sets the tag property to adjust the file name of the library. Ignored when using precompiled binaries.
build-name
The base name to use for the compiled library. Ignored when using precompiled binaries.
Examples:
# Find zlib in the default system location using zlib ; # Build zlib from source using zlib : 1.2.7 : <source>/home/steven/zlib-1.2.7 ; # Find zlib in /usr/local using zlib : 1.2.7 : <include>/usr/local/include <search>/usr/local/lib ; # Build zlib from source for msvc and find # prebuilt binaries for gcc. using zlib : 1.2.7 : <source>C:/Devel/src/zlib-1.2.7 : <toolset>msvc ; using zlib : 1.2.7 : : <toolset>gcc ;
Provides support for the bzip2 library. bzip2 can be configured either to use precompiled binaries or to build the library from source.
bzip2 can be initialized using the following syntax
using bzip2 : [version
] : [options
] : [condition
] : [is-default
] ;
Options for using a prebuilt library:
search
The directory containing the bzip2 binaries.
name
Overrides the default library name.
include
The directory containing the bzip2 headers.
If none of these options is specified, then the environmental variables BZIP2_LIBRARY_PATH, BZIP2_NAME, and BZIP2_INCLUDE will be used instead.
Options for building bzip2 from source:
source
The bzip2 source directory. Defaults to the environmental variable BZIP2_SOURCE.
tag
Sets the tag property to adjust the file name of the library. Ignored when using precompiled binaries.
build-name
The base name to use for the compiled library. Ignored when using precompiled binaries.
Examples:
# Find bzip in the default system location using bzip2 ; # Build bzip from source using bzip2 : 1.0.6 : <source>/home/sergey/src/bzip2-1.0.6 ; # Find bzip in /usr/local using bzip2 : 1.0.6 : <include>/usr/local/include <search>/usr/local/lib ; # Build bzip from source for msvc and find # prebuilt binaries for gcc. using bzip2 : 1.0.6 : <source>C:/Devel/src/bzip2-1.0.6 : <toolset>msvc ; using bzip2 : 1.0.6 : : <toolset>gcc ;
Boost.Build support for the Boost documentation tools is documented below.
To use xsltproc, you first need to configure it using the following syntax:
using xsltproc : [xsltproc
] ;
Where xsltproc
is the xsltproc executable.
If xsltproc
is not specified, and the
variable XSLTPROC is set, the value of XSLTPROC will be used.
Otherwise, xsltproc will be searched for in PATH.
The following options can be provided, using <
syntax:option-name
>option-value
xsl:param
Values should have the form
name
=value
xsl:path
Sets an additional search path for xi:include elements.
catalog
A catalog file used to rewrite remote URL's to a local copy.
The xsltproc module provides the following rules. Note that these operate on jam targets and are intended to be used by another toolset, such as boostbook, rather than directly by users.
xslt
rule xslt ( target : source stylesheet : properties * )
Runs xsltproc to create a single output file.
xslt-dir
rule xslt-dir ( target : source stylesheet : properties * : dirname )
Runs xsltproc to create multiple outputs in a directory.
dirname
is unused, but exists for
historical reasons. The output directory is determined from the
target.
To use boostbook, you first need to configure it using the following syntax:
using boostbook : [docbook-xsl-dir
] : [docbook-dtd-dir
] : [boostbook-dir
] ;
docbook-xsl-dir
is the DocBook XSL stylesheet
directory. If not provided, we use DOCBOOK_XSL_DIR from the environment
(if available) or look in standard locations. Otherwise, we let the
XML processor load the stylesheets remotely.
docbook-dtd-dir
is the DocBook DTD directory.
If not provided, we use DOCBOOK_DTD_DIR From the environment (if
available) or look in standard locations. Otherwise, we let the XML
processor load the DTD remotely.
boostbook-dir
is the BoostBook directory
with the DTD and XSL subdirs.
The boostbook module depends on xsltproc. For pdf or ps output, it also depends on fop.
The following options can be provided, using <
syntax:option-name
>option-value
format
Allowed values:
html
, xhtml
,
htmlhelp
, onehtml
,
man
, pdf
,
ps
, docbook
,
fo
, tests
.
The format
feature determines the type
of output produced by the boostbook rule.
The boostbook module defines a rule for creating a target following the common syntax.
boostbook
rule boostbook ( target-name : sources * : requirements * : default-build * )
Creates a boostbook target.
To use doxygen, you first need to configure it using the following syntax:
using doxygen : [name
] ;
name
is the doxygen command.
If it is not specified, it will be found in the PATH.
The doxygen module depends on the boostbook module when generating BoostBook XML.
The following options can be provided, using <
syntax:option-name
>option-value
doxygen:param
All the values of doxygen:param
are added to the doxyfile.
prefix
Specifies the common prefix of all headers when generating BoostBook XML. Everything before this will be stripped off.
reftitle
Specifies the title of the library-reference section, when generating BoostBook XML.
doxygen:xml-imagedir
When generating BoostBook XML, specifies the directory in which to place the images generated from LaTex formulae.
The path is interpreted relative to the current working directory, not relative to the Jamfile. This is necessary to match the behavior of BoostBook.
The doxygen module defines a rule for creating a target following the common syntax.
doxygen
rule doxygen ( target : sources * : requirements * : default-build * : usage-requirements * )
Creates a doxygen target. If the target name ends with .html, then this will generate an html directory. Otherwise it will generate BoostBook XML.
The quickbook module provides a generator to convert from Quickbook to BoostBook XML.
To use quickbook, you first need to configure it using the following syntax:
using quickbook : [command
] ;
command
is the quickbook executable.
If it is not specified, Boost.Build will compile it from source.
If it is unable to find the source it will search for a quickbook
executable in PATH.
The fop module provides generators to convert from XSL formatting objects to Postscript and PDF.
To use fop, you first need to configure it using the following syntax:
using fop : [fop-command
] : [java-home
] : [java
] ;
fop-command
is the command to run fop.
If it is not specified, Boost.Build will search for it in PATH and
FOP_HOME.
Either java-home
or
java
can be used to specify where to find java.