Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Reference

General information
Builtin rules
Builtin features
Builtin tools
Build process
Definitions
Generators

General information

Initialization

bjam's first job upon startup is to load the Jam code that implements the build system. To do this, it searches for a file called boost-build.jam, first in the invocation directory, then in its parent and so forth up to the filesystem root, and finally in the directories specified by the environment variable BOOST_BUILD_PATH. When found, the file is interpreted, and should specify the build system location by calling the boost-build rule:

rule boost-build ( location ? )

If location is a relative path, it is treated as relative to the directory of boost-build.jam. The directory specified by that location and the directories in BOOST_BUILD_PATH are then searched for a file called bootstrap.jam, which is expected to bootstrap the build system. This arrangement allows the build system to work without any command-line or environment variable settings. For example, if the build system files were located in a directory "build-system/" at your project root, you might place a boost-build.jam at the project root containing:

boost-build build-system ;

In this case, running bjam anywhere in the project tree will automatically find the build system.

The default bootstrap.jam, after loading some standard definitions, loads two site-config.jam and user-config.jam.

Builtin rules

This section contains the list of all rules that can be used in Jamfile—both rules that define new targets and auxiliary rules.

exe

Creates an executable file. See the section called “Programs”.

lib

Creates an library file. See the section called “Libraries”.

install

Installs built targets and other files. See the section called “Installing”.

alias

Creates an alias for other targets. See the section called “Alias”.

unit-test

Creates an executable that will be automatically run. See the section called “Testing”.

compile, compile-fail, link, link-fail, run, run-fail

Specialized rules for testing. See the section called “Testing”.

obj

Creates an object file. Useful when a single source file must be compiled with special properties.

glob

The glob rule takes a list shell pattern and returns the list of files in the project's source directory that match the pattern. For example:

lib tools : [ glob *.cpp ] ;
        

It is possible to also pass a second argument—the list of exclude patterns. The result will then include the list of files patching any of include patterns, and not matching any of the exclude patterns. For example:

lib tools : [ glob *.cpp : file_to_exclude.cpp bad*.cpp ] ;
        

glob-tree

The glob-tree is similar to the glob except that it operates recursively from the directory of the containing Jamfile. For example:

ECHO [ glob-tree *.cpp : .svn ] ;
        

will print the names of all C++ files in your project. The .svn exclude pattern prevents the glob-tree rule from entering administrative directories of the Subversion version control system.

project

Declares project id and attributes, including project requirements. See the section called “Projects”.

use-project

Assigns a symbolic project ID to a project at a given path. This rule must be better documented!

explicit

The explicit rule takes a single parameter—a list of target names. The named targets will be marked explicit, and will be built only if they are explicitly requested on the command line, or if their dependents are built. Compare this to ordinary targets, that are built implicitly when their containing project is built.

constant

Sets project-wide constant. Takes two parameters: variable name and a value and makes the specified variable name accessible in this Jamfile and any child Jamfiles. For example:

constant VERSION : 1.34.0 ;
        

path-constant

Same as constant except that the value is treated as path relative to Jamfile location. For example, if bjam is invoked in the current directory, and Jamfile in helper subdirectory has:

path-constant DATA : data/a.txt ;
        

then the variable DATA will be set to helper/data/a.txt, and if bjam is invoked from the helper directory, then the variable DATA will be set to data/a.txt.

build-project

Cause some other project to be built. This rule takes a single parameter—a directory name relative to the containing Jamfile. When the containing Jamfile is built, the project located at that directory will be built as well. At the moment, the parameter to this rule should be a directory name. Project ID or general target references are not allowed.

test-suite

This rule is deprecated and equivalent to alias.

Builtin features

This section documents the features that are built-in into Boost.Build. For features with a fixed set of values, that set is provided, with the default value listed first.

variant

A feature combining several low-level features, making it easy to request common build configurations.

Allowed values: debug, release, profile.

The value debug expands to

<optimization>off <debug-symbols>on <inlining>off <runtime-debugging>on

The value release expands to

<optimization>speed <debug-symbols>off <inlining>full <runtime-debugging>off

The value profile expands to the same as release, plus:

<profiling>on <debug-symbols>on

Users can define their own build variants using the variant rule from the common module.

Note: Runtime debugging is on in debug builds to suit the expectations of people used to various IDEs.

link

Allowed values: shared, static

A feature controling how libraries are built.

runtime-link

Allowed values: shared, static

Controls if a static or shared C/C++ runtime should be used. There are some restrictions how this feature can be used, for example on some compilers an application using static runtime should not use shared libraries at all, and on some compilers, mixing static and shared runtime requires extreme care. Check your compiler documentation for more details.

threading

Allowed values: single, multi

Controls if the project should be built in multi-threaded mode. This feature does not necessary change code generation in the compiler, but it causes the compiler to link to additional or different runtime libraries, and define additional preprocessor symbols (for example, _MT on Windows and _REENTRANT on Linux). How those symbols affect the compiled code depends on the code itself.

source
The <source>X feature has the same effect on building a target as putting X in the list of sources. It is useful when you want to add the same source to all targets in the project (you can put <source> in requirements) or to conditionally include a source (using conditional requirements, see the section called “Conditions and alternatives”). See also the <library> feature.
library
This feature is almost equivalent to the <source> feature, except that it takes effect only for linking. When you want to link all targets in a Jamfile to certain library, the <library> feature is preferred over <source>X -- the latter will add the library to all targets, even those that have nothing to do with libraries.
dependency
Introduces a dependency on the target named by the value of this feature (so it will be brought up-to-date whenever the target being declared is). The dependency is not used in any other way.
use
Introduces a dependency on the target named by the value of this feature (so it will be brought up-to-date whenever the target being declared is), and adds its usage requirements to the build properties of the target being declared. The dependency is not used in any other way. The primary use case is when you want the usage requirements (such as #include paths) of some library to be applied, but do not want to link to it.
dll-path
Specify an additional directory where the system should look for shared libraries when the executable or shared library is run. This feature only affects Unix compilers. Plase see the section called “ Why are the dll-path and hardcode-dll-paths properties useful? ” in the section called “Frequently Asked Questions” for details.
hardcode-dll-paths

Controls automatic generation of dll-path properties.

Allowed values: true, false. This property is specific to Unix systems. If an executable is built with <hardcode-dll-paths>true, the generated binary will contain the list of all the paths to the used shared libraries. As the result, the executable can be run without changing system paths to shared libraries or installing the libraries to system paths. This is very convenient during development. Plase see the FAQ entry for details. Note that on Mac OSX, the paths are unconditionally hardcoded by the linker, and it is not possible to disable that behaviour.

cflags, cxxflags, linkflags
The value of those features is passed without modification to the corresponding tools. For cflags that is both the C and C++ compilers, for cxxflags that is the C++ compiler and for linkflags that is the linker. The features are handy when you are trying to do something special that cannot be achieved by a higher-level feature in Boost.Build.
include
Specifies an additional include path that is to be passed to C and C++ compilers.
warnings
The <warnings> feature controls the warning level of compilers. It has the following values:
  • off - disables all warnings.

  • on - enables default warning level for the tool.

  • all - enables all warnings.

Default value is all.
warnings-as-errors
The <warnings-as-errors> makes it possible to treat warnings as errors and abort compilation on a warning. The value on enables this behaviour. The default value is off.
build

Allowed values: no

The build feature is used to conditionally disable build of a target. If <build>no is in properties when building a target, build of that target is skipped. Combined with conditional requirements this allows you to skip building some target in configurations where the build is known to fail.

tag

The tag feature is used to customize the name of the generated files. The value should have the form:

@rulename

where rulename should be a name of a rule with the following signature:

rule tag ( name : type ? : property-set )

The rule will be called for each target with the default name computed by Boost.Build, the type of the target, and property set. The rule can either return a string that must be used as the name of the target, or an empty string, in which case the default name will be used.

Most typical use of the tag feature is to encode build properties, or library version in library target names. You should take care to return non-empty string from the tag rule only for types you care about — otherwise, you might end up modifying names of object files, generated header file and other targets for which changing names does not make sense.

debug-symbols

Allowed values: on, off.

The debug-symbols feature specifies if produced object files, executables and libraries should include debug information. Typically, the value of this feature is implicitly set by the variant feature, but it can be explicitly specified by the user. The most common usage is to build release variant with debugging information.

target-os

The operating system for which the code is to be generated. The compiler you used should be the compiler for that operating system. This option causes Boost.Build to use naming conventions suitable for that operating system, and adjust build process accordingly. For example, with gcc, it controls if import libraries are produced for shared libraries or not.

The complete list of possible values for this feature is: aix, bsd, cygwin, darwin, freebsd, hpux, iphone, linux, netbsd, openbsd, osf, qnx, qnxnto, sgi, solaris, unix, unixware, windows.

See the section called “Cross-compilation” for details of crosscompilation

architecture

The architecture features specifies the general processor familty to generate code for.

instruction-set

Allowed values: depend on the used toolset.

The instruction-set specifies for which specific instruction set the code should be generated. The code in general might not run on processors with older/different instruction sets.

While Boost.Build allows a large set of possible values for this features, whether a given value works depends on which compiler you use. Please see the section called “C++ Compilers” for details.

address-model

Allowed values: 32, 64.

The address-model specifies if 32-bit or 64-bit code should be generated by the compiler. Whether this feature works depends on the used compiler, its version, how the compiler is configured, and the values of the architecture instruction-set features. Please see the section called “C++ Compilers” for details.

c++-template-depth

Allowed values: Any positive integer.

This feature allows configuring a C++ compiler with the maximal template instantiation depth parameter. Specific toolsets may or may not provide support for this feature depending on whether their compilers provide a corresponding command-line option.

Note: Due to some internal details in the current Boost Build implementation it is not possible to have features whose valid values are all positive integer. As a workaround a large set of allowed values has been defined for this feature and, if a different one is needed, user can easily add it by calling the feature.extend rule.

embed-manifest

Allowed values: on, off.

This feature is specific to the msvc toolset (see the section called “Microsoft Visual C++”), and controls whether the manifest files should be embedded inside executables and shared libraries, or placed alongside them. This feature corresponds to the IDE option found in the project settings dialog, under Configuration PropertiesManifest ToolInput and OutputEmbed manifest.

Builtin tools

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.

C++ Compilers

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.

GNU C++

The gcc module supports the GNU C++ compiler on Linux, a number of Unix-like system including MacOS X, SunOS and BeOS, and on Windows (either Cygwin or MinGW).

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 <option-name>option-value syntax:

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.

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.

In order to compile 64-bit applications, you have to specify address-model=64, and the instruction-set feature should refer to a 64 bit processor. Currently, those include nocona, opteron, athlon64 and athlon-fx.
Microsoft Visual C++

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 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 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 <option-name>option-value syntax:

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

64-bit support

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:

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

  2. When compiling, use address-model=64, to generate AMD64 code.

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

Intel C++

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 <option-name>option-value syntax:

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.

HP aC++ compiler

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 <option-name>option-value syntax:

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.

Borland C++ Compiler

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 <option-name>option-value syntax:

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.

Comeau C/C++ Compiler

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 <option-name>option-value syntax:

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.

Code Warrior

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 aquisition 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 <option-name>option-value syntax:

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.

Digital Mars C/C++ Compiler

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 <option-name>option-value syntax:

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.

HP C++ Compiler for Tru64 Unix

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 <option-name>option-value syntax:

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.

Sun Studio

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 intializing the sun module:

-library=stlport4 -features=tmplife -features=tmplrefstatic
          

See the Sun C++ Frontend Tales for details.

The following options can be provided, using <option-name>option-value syntax:

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.

Starting with Sun Studio 12, you can create 64-bit applications by using the address-model=64 property.
IBM Visual Age

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.

Third-party libraries

Boost.Build provides special support for some third-party C++ libraries, documented below.

STLport library

The STLport library is an alternative implementation of C++ runtime library. Boost.Build supports using that library on Windows platfrom. 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.

Build process

The general overview of the build process was given in the user documentation. This section provides additional details, and some specific rules.

To recap, building a target with specific properties includes the following steps:

  1. applying default build,

  2. selecting the main target alternative to use,

  3. determining "common" properties,

  4. building targets referred by the sources list and dependency properties,

  5. adding the usage requirements produces when building dependencies to the "common" properties,

  6. building the target using generators,

  7. computing the usage requirements to be returned.

Alternative selection

When there are several alternatives, one of them must be selected. The process is as follows:

  1. For each alternative condition is defined as the set of base properties in requirements. [Note: it might be better to specify the condition explicitly, as in conditional requirements].
  2. An alternative is viable only if all properties in condition are present in build request.
  3. If there's one viable alternative, it's choosen. Otherwise, an attempt is made to find one best alternative. An alternative a is better than another alternative b, iff the set of properties in b's condition is a strict subset of the set of properities of 'a's condition. If there's one viable alternative, which is better than all others, it's selected. Otherwise, an error is reported.

Determining common properties

The "common" properties is a somewhat artificial term. Those are the intermediate property set from which both the build request for dependencies and properties for building the target are derived.

Since default build and alternatives are already handled, we have only two inputs: build requests and requirements. Here are the rules about common properties.

  1. Non-free feature can have only one value

  2. A non-conditional property in requirement in always present in common properties.

  3. A property in build request is present in common properties, unless (2) tells otherwise.

  4. If either build request, or requirements (non-conditional or conditional) include an expandable property (either composite, or property with specified subfeature value), the behaviour is equivalent to explicitly adding all expanded properties to build request or requirements.

  5. If requirements include a conditional property, and condiiton of this property is true in context of common properties, then the conditional property should be in common properties as well.

  6. If no value for a feature is given by other rules here, it has default value in common properties.

Those rules are declarative, they don't specify how to compute the common properties. However, they provide enough information for the user. The important point is the handling of conditional requirements. The condition can be satisfied either by property in build request, by non-conditional requirements, or even by another conditional property. For example, the following example works as expected:

exe a : a.cpp
      : <toolset>gcc:<variant>release
        <variant>release:<define>FOO ;

Definitions

Features and properties

A feature is a normalized (toolset-independent) aspect of a build configuration, such as whether inlining is enabled. Feature names may not contain the '>' character.

Each feature in a build configuration has one or more associated values. Feature values for non-free features may not contain the '<', ':', or '=' characters. Feature values for free features may not contain the '<' character.

A property is a (feature,value) pair, expressed as <feature>value.

A subfeature is a feature that only exists in the presence of its parent feature, and whose identity can be derived (in the context of its parent) from its value. A subfeature's parent can never be another subfeature. Thus, features and their subfeatures form a two-level hierarchy.

A value-string for a feature F is a string of the form value-subvalue1-subvalue2...-subvalueN, where value is a legal value for F and subvalue1...subvalueN are legal values of some of F's subfeatures. For example, the properties <toolset>gcc <toolset-version>3.0.1 can be expressed more conscisely using a value-string, as <toolset>gcc-3.0.1.

A property set is a set of properties (i.e. a collection without duplicates), for instance: <toolset>gcc <runtime-link>static.

A property path is a property set whose elements have been joined into a single string separated by slashes. A property path representation of the previous example would be <toolset>gcc/<runtime-link>static.

A build specification is a property set that fully describes the set of features used to build a target.

Property Validity

For free features, all values are valid. For all other features, the valid values are explicitly specified, and the build system will report an error for the use of an invalid feature-value. Subproperty validity may be restricted so that certain values are valid only in the presence of certain other subproperties. For example, it is possible to specify that the <gcc-target>mingw property is only valid in the presence of <gcc-version>2.95.2.

Feature Attributes

Each feature has a collection of zero or more of the following attributes. Feature attributes are low-level descriptions of how the build system should interpret a feature's values when they appear in a build request. We also refer to the attributes of properties, so that an incidental property, for example, is one whose feature has the incidental attribute.

  • incidental

    Incidental features are assumed not to affect build products at all. As a consequence, the build system may use the same file for targets whose build specification differs only in incidental features. A feature that controls a compiler's warning level is one example of a likely incidental feature.

    Non-incidental features are assumed to affect build products, so the files for targets whose build specification differs in non-incidental features are placed in different directories as described in "target paths" below. [ where? ]

  • propagated

    Features of this kind are propagated to dependencies. That is, if a main target is built using a propagated property, the build systems attempts to use the same property when building any of its dependencies as part of that main target. For instance, when an optimized exectuable is requested, one usually wants it to be linked with optimized libraries. Thus, the <optimization> feature is propagated.

  • free

    Most features have a finite set of allowed values, and can only take on a single value from that set in a given build specification. Free features, on the other hand, can have several values at a time and each value can be an arbitrary string. For example, it is possible to have several preprocessor symbols defined simultaneously:

    <define>NDEBUG=1 <define>HAS_CONFIG_H=1
    
  • optional

    An optional feature is a feature that is not required to appear in a build specification. Every non-optional non-free feature has a default value that is used when a value for the feature is not otherwise specified, either in a target's requirements or in the user's build request. [A feature's default value is given by the first value listed in the feature's declaration. -- move this elsewhere - dwa]

  • symmetric

    A symmetric feature's default value is not automatically included in build variants. Normally a feature only generates a subvariant directory when its value differs from the value specified by the build variant, leading to an assymmetric subvariant directory structure for certain values of the feature. A symmetric feature, when relevant to the toolset, always generates a corresponding subvariant directory.

  • path

    The value of a path feature specifies a path. The path is treated as relative to the directory of Jamfile where path feature is used and is translated appropriately by the build system when the build is invoked from a different directory

  • implicit

    Values of implicit features alone identify the feature. For example, a user is not required to write "<toolset>gcc", but can simply write "gcc". Implicit feature names also don't appear in variant paths, although the values do. Thus: bin/gcc/... as opposed to bin/toolset-gcc/.... There should typically be only a few such features, to avoid possible name clashes.

  • composite

    Composite features actually correspond to groups of properties. For example, a build variant is a composite feature. When generating targets from a set of build properties, composite features are recursively expanded and added to the build property set, so rules can find them if necessary. Non-composite non-free features override components of composite features in a build property set.

  • dependency

    The value of dependency feature if a target reference. When used for building of a main target, the value of dependency feature is treated as additional dependency.

    For example, dependency features allow to state that library A depends on library B. As the result, whenever an application will link to A, it will also link to B. Specifying B as dependency of A is different from adding B to the sources of A.

Features that are neither free nor incidental are called base features.

Feature Declaration

The low-level feature declaration interface is the feature rule from the feature module:

rule feature ( name : allowed-values * : attributes * )

A feature's allowed-values may be extended with the feature.extend rule.

Build Variants

A build variant, or (simply variant) is a special kind of composite feature that automatically incorporates the default values of features that . Typically you'll want at least two separate variants: one for debugging, and one for your release code. [ Volodya says: "Yea, we'd need to mention that it's a composite feature and describe how they are declared, in pacticular that default values of non-optional features are incorporated into build variant automagically. Also, do we wan't some variant inheritance/extension/templates. I don't remember how it works in V1, so can't document this for V2.". Will clean up soon -DWA ]

Property refinement

When a target with certain properties is requested, and that target requires some set of properties, it is needed to find the set of properties to use for building. This process is called property refinement and is performed by these rules

  1. Each property in the required set is added to the original property set
  2. If the original property set includes property with a different value of non free feature, that property is removed.

Conditional properties

Sometime it's desirable to apply certain requirements only for a specific combination of other properties. For example, one of compilers that you use issues a pointless warning that you want to suppress by passing a command line option to it. You would not want to pass that option to other compilers. Conditional properties allow you to do just that. Their syntax is:

        property ( "," property ) * ":" property
      

For example, the problem above would be solved by:

exe hello : hello.cpp : <toolset>yfc:<cxxflags>-disable-pointless-warning ;

The syntax also allows several properties in the condition, for example:

exe hello : hello.cpp : <os>NT,<toolset>gcc:<link>static ;

Target identifiers and references

Target identifier is used to denote a target. The syntax is:

target-id -> (project-id | target-name | file-name )
              | (project-id | directory-name) "//" target-name
project-id -> path
target-name -> path
file-name -> path
directory-name -> path

This grammar allows some elements to be recognized as either

  • project id (at this point, all project ids start with slash).
  • name of target declared in current Jamfile (note that target names may include slash).
  • a regular file, denoted by absolute name or name relative to project's sources location.

To determine the real meaning a check is made if project-id by the specified name exists, and then if main target of that name exists. For example, valid target ids might be:

a                                    -- target in current project
lib/b.cpp                            -- regular file
/boost/thread                        -- project "/boost/thread"
/home/ghost/build/lr_library//parser -- target in specific project

Rationale:Target is separated from project by special separator (not just slash), because:

  • It emphasises that projects and targets are different things.
  • It allows to have main target names with slashes.

Target reference is used to specify a source target, and may additionally specify desired properties for that target. It has this syntax:

target-reference -> target-id [ "/" requested-properties ]
requested-properties -> property-path

For example,

          exe compiler : compiler.cpp libs/cmdline/<optimization>space ;
        

would cause the version of cmdline library, optimized for space, to be linked in even if the compiler executable is build with optimization for speed.

Generators

[Warning] Warning

The information is this section is likely to be outdated and misleading.

To construct a main target with given properties from sources, it is required to create a dependency graph for that main target, which will also include actions to be run. The algorithm for creating the dependency graph is described here.

The fundamental concept is generator. If encapsulates the notion of build tool and is capable to converting a set of input targets into a set of output targets, with some properties. Generator matches a build tool as closely as possible: it works only when the tool can work with requested properties (for example, msvc compiler can't work when requested toolset is gcc), and should produce exactly the same targets as the tool (for example, if Borland's linker produces additional files with debug information, generator should also).

Given a set of generators, the fundamental operation is to construct a target of a given type, with given properties, from a set of targets. That operation is performed by rule generators.construct and the used algorithm is described below.

Selecting and ranking viable generators

Each generator, in addition to target types that it can produce, have attribute that affects its applicability in particular sitiation. Those attributes are:

  1. Required properties, which are properties absolutely necessary for the generator to work. For example, generator encapsulating the gcc compiler would have <toolset>gcc as required property.
  2. Optional properties, which increase the generators suitability for a particual build.

Generator's required and optional properties may not include either free or incidental properties. (Allowing this would greatly complicate caching targets).

When trying to construct a target, the first step is to select all possible generators for the requested target type, which required properties are a subset of requested properties. Generators that were already selected up the call stack are excluded. In addition, if any composing generators were selected up the call stack, all other composing generators are ignored (TODO: define composing generators). The found generators are assigned a rank, which is the number of optional properties present in requested properties. Finally, generators with highest rank are selected for futher processing.

Running generators

When generators are selected, each is run to produce a list of created targets. This list might include targets that are not of requested types, because generators create the same targets as some tool, and tool's behaviour is fixed. (Note: should specify that in some cases we actually want extra targets). If generator fails, it returns an empty list. Generator is free to call 'construct' again, to convert sources to the types it can handle. It also can pass modified properties to 'construct'. However, a generator is not allowed to modify any propagated properties, otherwise when actually consuming properties we might discover that the set of propagated properties is different from what was used for building sources.

For all targets that are not of requested types, we try to convert them to requested type, using a second call to construct. This is done in order to support transformation sequences where single source file expands to several later. See this message for details.

Selecting dependency graph

After all generators are run, it is necessary to decide which of successfull invocation will be taken as final result. At the moment, this is not done. Instead, it is checked whether all successfull generator invocation returned the same target list. Error is issued otherwise.

Property adjustment

Because target location is determined by the build system, it is sometimes necessary to adjust properties, in order to not break actions. For example, if there's an action that generates a header, say "a_parser.h", and a source file "a.cpp" which includes that file, we must make everything work as if a_parser.h is generated in the same directory where it would be generated without any subvariants.

Correct property adjustment can be done only after all targets are created, so the approach taken is:

  1. When dependency graph is constructed, each action can be assigned a rule for property adjustment.

  2. When virtual target is actualized, that rule is run and return the final set of properties. At this stage it can use information of all created virtual targets.

In case of quoted includes, no adjustment can give 100% correct results. If target dirs are not changed by build system, quoted includes are searched in "." and then in include path, while angle includes are searched only in include path. When target dirs are changed, we'd want to make quoted includes to be search in "." then in additional dirs and then in the include path and make angle includes be searched in include path, probably with additional paths added at some position. Unless, include path already has "." as the first element, this is not possible. So, either generated headers should not be included with quotes, or first element of include path should be ".", which essentially erases the difference between quoted and angle includes. Note: the only way to get "." as include path into compiler command line is via verbatim compiler option. In all other case, Boost.Build will convert "." into directory where it occurs.

Transformations cache

Under certain conditions, an attempt is made to cache results of transformation search. First, the sources are replaced with targets with special name and the found target list is stored. Later, when properties, requested type, and source type are the same, the store target list is retrieved and cloned, with appropriate change in names.


PrevUpHomeNext