However, that only happens when using the Boost. Python project file e. If instead you are linking against separately-compiled Boost. Python binaries, you should set up a user - config. If you have several versions of Python installed, or Python is installed in an unusual way, you may want to supply any or all of the following optional parameters to using python. Should be in Major. Minor format, for example, 2. Do not include the subminor version i. If you have multiple Python versions installed, the version will usually be the only configuration argument required.
Alternatively, the installation prefix for Python libraries and header files. Only use the alternative formulation if there is no appropriate Python executable available. Some people find bjam to be extremely problematic under Windows. If you are having trouble, I would suggest trying the CMake build system branch of Boost. This is also very helpful with compiling the libs for use with Intel's compilers which tend to be badly supported by the bjam build system.
Another advantage is that CMake generates Visual Studio solution files, meaning that you can adjust build settings or rebuild components with a familiar interface. CMake in Windows has a nice GUI which makes configuring the build very easy, as well as providing a way to easily adjust them at a later stage. Cmake - Boost Wiki - Boost. Cmake - Gitorious. You should now have the. The following program reads a sequence of integers from standard input, uses Boost.
Lambda to multiply each number by three, and writes them to standard output:. To build the examples in this guide, you can use an Integrated Development Environment IDE like Visual Studio, or you can issue commands from the command prompt.
Since every IDE and compiler has different options and Microsoft's are by far the dominant compilers on Windows, we only give specific directions here for Visual Studio and. NET IDEs and their respective command prompt compilers using the command prompt is a bit simpler. If you are using another compiler or IDE, it should be relatively easy to adapt these instructions to your environment. In Windows, a command-line tool is invoked by typing its name, optionally followed by arguments, into a Command Prompt window and pressing the Return or Enter key.
All commands are executed within the context of a current directory in the filesystem. To set the current directory, type:. Some examples on this page use that technique to save horizontal space. Right-click example in the Solution Explorer pane and select Properties from the resulting pop-up menu.
Replace the contents of the example. To test your application, hit the F5 key and type the following into the resulting window, followed by the Return key:. In that window, set the current directory to a suitable location for creating some temporary files and type the following command followed by the Return key:. Don't be alarmed if you see compiler warnings originating in Boost headers. We try to eliminate them, but doing so isn't always practical. If you're seeing compilation errors at this point in the tutorial, check to be sure you've copied the example program correctly and that you've correctly identified the Boost root directory.
If you want to use any of the separately-compiled Boost libraries, you'll need to acquire library binaries. Open the command prompt and change your current directory to the Boost root directory.
Then, type the following commands:. The first command prepares the Boost. Build system for use. The second command invokes Boost. Build to build the separately-compiled Boost libraries. Please consult the Boost. Build documentation for a list of allowed options. Build to create your own binaries. Build is a text-based system for developing, testing, and installing software. First, you'll need to build and install it. To do this:. First, find the toolset corresponding to your compiler in the following table an up-to-date list is always available in the Boost.
Every module has two special variables. Call the given rule locally in the given module. Load the indicated module and import rule names into the current module. If rename-opt is supplied, it must have the same number of elements as rules-opt. Performs various path manipulations. Paths are always in a 'normalized' representation.
In it, a path may be either:. In plain english, a path can be rooted, '.. The path may not contain ".. Concatenates the passed path elements. Generates an error if any element other than the first one is rooted. Skips any empty or undefined path elements.
Returns the list of files matching the given pattern in the specified directory. Both directories and patterns are supplied as portable paths. Each slash separated element of a pattern can contain the following special characters:.
Recursive version of glob. Builds the glob of files while also searching in the subdirectories of the given roots. An optional set of exclusion patterns will filter out the matching entries from the result.
The exclusions also apply to the subdirectory scanning, such that directories that match the exclusion patterns will not be searched. Find out the absolute name of path and return the list of all the parents, starting with the immediate one. Parents are returned as relative names. Assuming child is a subdirectory of parent , return the relative path from parent to child. A character range such as "[a-z]" matches any character between "a" and "z".
Returns the concatenated results of applying regex. Match string against pattern , and return the elements indicated by indices. Matches all elements of list against the pattern and returns a list of elements indicated by indices of all successful matches. If indices is omitted returns a list of first parenthesized groups of all successful matches. Escapes all of the characters in symbols using the escape symbol escape-symbol for the given string, and returns the escaped string.
Replaces occurrences of a match string in a given string and returns the new string. The match string can be a regex expression.
Replaces occurrences of a match string in a given list of strings and returns a list of new strings. Various useful list functions. Also note that most predicates can be multi-element lists. In that case, all but the first element are prepended to the first argument which is passed to the rule named by the first element.
Join the elements of s into one long string. If joint is supplied, it is used as a separator. Removes duplicates from list. If stable is passed, then the order of the elements will be unchanged. Returns the maximum number in elements. Uses ordered for comparisons or numbers. Returns all of elements for which the corresponding element in the parallel list rank is equal to the maximum value in rank.
This module defines the install rule, used to copy a set of targets to a single location. Returns the path to a named installation directory. Otherwise it tries to construct the default value of the path recursively getting the path to name 's registered base named directory and relative path. The argument package-name is used to construct the path for named directories that were registered with package-suffix option and also to construct install-prefix when targeting Windows.
Returns the package name that will be used for install targets when constructing installation location. Otherwise it deduces the package name using project-module 's attributes. It traverses the project hierarchy up to the root searching for the first project with an id. Registers a target type, possible derived from a base-type. Providing a list of suffixes here is a shortcut for separately calling the register-suffixes rule with the given suffixes and the set-generated-target-suffix rule with the first given suffix.
Specifies that files with suffix from suffixes be recognized as targets of type type. Issues an error if a different type is already specified for any of the suffixes. Returns true if type is equal to base or has base as its direct or indirect base. Sets a file suffix to be used when generating a target of type with the specified properties. Can be called with no properties if no suffix has already been specified for the type. The suffix parameter can be an empty string "" to indicate that no suffix should be used.
Note that this does not cause files with suffix to be automatically recognized as being of type. Two different types can use the same suffix for their generated files but only one type can be auto-detected for a file with that suffix. User should explicitly specify which one using the register-suffixes rule. If suffix is not yet specified, sets it.
Sets a target prefix that should be used when generating targets of type with the specified properties. Can be called with empty properties if no prefix for type has been specified yet. The prefix parameter can be empty string "" to indicate that no prefix should be used. If prefix is not yet specified, sets it.
Returns file type given its name. If there are several dots in filename, tries each suffix. Generates virtual targets for this abstract target using the specified properties, unless a different value of some feature is required by the target. This is an abstract method which must be overridden by derived classes. If property-set is empty, performs the default build of this target, in a way specific to the derived class.
Overrides abstract-target. Generates virtual targets for all the targets contained in this project. Returns a main-target class instance corresponding to name.
Can only be called after the project has been fully loaded. Returns whether a main-target with the specified name exists. Find and return the target with the specified id, treated relative to self.
Id may specify either a target or a file name with the target taking priority. May report an error or return nothing if the target is not found depending on the no-error parameter.
A main-target represents a named top-level target in a Jamfile. Select an alternative for this main target, by finding all alternatives whose requirements are satisfied by property-set and picking the one with the longest requirements set.
Returns the result of calling generate on that alternative. Implements the most standard way of constructing main target alternative from sources.
Allows sources to be either files or other main targets and handles generation of those dependency targets. Determines final build properties, generates sources, and calls construct.
This method should not be overridden. Constructs virtual targets for this abstract target. Returns a usage-requirements property-set and a list of virtual targets. Should be overridden in derived classes. Rules for creating typed targets are defined automatically for each type. Implements basic-target. Attempts to create a target of the correct type using generators appropriate for the given property-set.
Returns a property-set containing the usage requirements and a list of virtual targets. No two instances of the class are equal. To maintain this property, the 'property-set. Instances are immutable. Returns a property-set containing all the propagated properties in this property-set. Returns a new property-set containing the union of the properties in this property-set and in ps. Link add , except that it takes a list of properties instead of a property-set.
Refines properties by overriding any non-free and non-conditional properties for which a different value is specified in ps. Returns the resulting property-set.
The general overview of the build process was given in the user documentation. This section provides additional details, and some specific rules. For each alternative, its condition is defined as the set of base properties in its requirements. Conditional properties are excluded. An alternative is viable only if all properties in its condition are present in the build request. Otherwise, an attempt is made to find the best alternative. Otherwise, an error is reported. This is the intermediate property set from which both the build request for dependencies and the properties for building the target are derived.
Since the default build and alternatives are already handled, we have only two inputs: the build request and the requirements. Here are the rules about common properties. A property in the build request is present in common properties, unless it is overridden by a property in the requirements.
If either the build request, or the requirements non-conditional or conditional include an expandable property either composite, or with a specified sub-feature value , the behavior is equivalent to explicitly adding all the expanded properties to the build request or the requirements respectively.
If the requirements include a conditional property , and the condition of this property is true in the context of common properties, then the conditional property should be in common properties as well. If no value for a feature is given by other rules here, it has default value in common properties.
These rules are declarative. However, they provide enough information for the user. The important point is the handling of conditional requirements. The condition can be satisfied either by a property in the build request, by non-conditional requirements, or even by another conditional property. For example, the following example works as expected:. Several factors determine the location of a concrete file target.
All files in a project are built under the directory bin unless this is overridden by the build-dir project attribute. Under bin is a path that depends on the properties used to build each target. This path is uniquely determined by all non-free, non-incidental properties. Sometimes the paths produced by B2 can become excessively long. There are a couple of command line options that can help with this.
For example, link-static becomes lnk-sttc. The --hash option reduces the path to a single directory using an MD5 hash. There are two features that affect the build directory. This is generally discouraged, as it precludes variant builds. A feature is a normalized toolset-independent aspect of a build configuration, such as whether inlining is enabled. Each feature in a build configuration has one or more associated value s. 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.
Thus, features and their subfeatures form a two-level hierarchy. A property set is a set of properties i. A property path is a property set whose elements have been joined into a single string separated by slashes. A build specification is a property set that fully describes the set of features used to build a target.
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. Each feature has a collection of zero or more of the following attributes. We also refer to the attributes of properties, so that an incidental property, for example, is one whose feature has the incidental attribute. 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. 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. 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 executable is requested, one usually wants it to be linked with optimized libraries. 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:. An optional feature is a feature that is not required to appear in a build specification.
Normally a feature only generates a sub-variant directory when its value differs from its default value, leading to an asymmetric sub-variant directory structure for certain values of the feature.
A symmetric feature always generates a corresponding sub-variant directory. 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.
Values of implicit features alone identify the feature. There should typically be only a few such features, to avoid possible name clashes. 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.
The value of a dependency feature is 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. The low-level feature declaration interface is the feature rule from the feature module:.
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.
If the original property set includes property with a different value of non free feature, that property is removed.
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:. To determine the real meaning the possible interpretations are checked in this order. For example, valid target ids might be:. Rationale: Target is separated from project by special separator not just slash , because:. Target reference is used to specify a source target, and may additionally specify desired properties for that target. It has this syntax:.
B2 comes with a debugger for Jamfiles. To run the debugger, start B2 with b2 -dconsole. The run command is used to start a new b2 subprocess for debugging. The arguments to run are passed on the command line. If a child process is already running, it will be terminated before the new child is launched.
When the program is paused continue will resume execution. The step command will advance the program by a single statement, stopping on entry to another function or return from the current function.
Breakpoints are set using the break command. The location of the breakpoint can be specified as either the name of a function including the module name or or a file name and line number of the form file:line.
When a breakpoint is created it is given a unique id which is used to identify it for other commands. A breakpoint can be temporarily disabled using the disable command.
While a breakpoint is disabled, the child will not stop when it is hit. A disabled breakpoint can be activated again with enable. Breakpoints can be removed permanently with delete or clear. The difference between them is that delete takes the breakpoint id while clear takes the location of the breakpoint as originally specified to break.
Before we start, be sure you have read and understood the concept of metatarget, Concepts , which is critical to understanding the remaining material. Object that is created from declarations in Jamfiles. May be called with a set of properties to produce concrete targets.
Low-level concrete target that is specific to Boost. Jam build engine. In most cases, you will only have to deal with concrete targets and the process that creates concrete targets from metatargets. Extending metatarget level is rarely required. The jam targets are typically only used inside the command line patterns. Metatarget is an object that records information specified in Jamfile, such as metatarget kind, name, sources and properties, and can be called with specific properties to generate concrete targets.
At the code level it is represented by an instance of class derived from abstract-target. The generate method takes the build properties as an instance of the property-set class and returns a list containing:.
The abstract-target class has three immediate derived classes:. The generate method of this class builds all targets in the project that are not marked as explicit. This class also should not be subclassed. The generate method of this class selects an alternative to build, and calls the generate method of that alternative. This is base class, with a number of derived classes. The generate method processes the target requirements and requested build properties to determine final properties for the target, builds all sources, and finally calls the abstract construct method with the list of source virtual targets, and the final properties.
The instances of the classes derived from basic-target are typically created when Jamfile calls a metatarget rule, such as such as exe. It it permissible to create a custom class derived from basic-target and create new metatarget rule that creates instance of such target. That class is associated with a type and relays to generators to construct concrete targets of that type. This process will be explained below.
When a new type is declared, a new metatarget rule is automatically defined. That rule creates new instance of type-target, associated with that type. Concrete targets are represented by instance of classes derived from virtual-target. The most commonly used subclass is file-target. The action, in turn, hold a list of source targets. It also holds the property-set instance with the build properties that should be used for the action.
The first line creates an instance of the action class. The first parameter is the list of sources. The second parameter is the name a jam-level action. The third parameter is the property-set applying to this action.
The second line creates a target. We specify a name, a type and a project. We also pass the action object created earlier. If the action creates several targets, we can repeat the second line several times.
In some cases, code that creates concrete targets may be invoked more than once with the same properties. Returning two different instances of file-target that correspond to the same file clearly will result in problems. Therefore, whenever returning targets you should pass them via the virtual-target. In theory, every kind of metatarget in B2 like exe , lib or obj could be implemented by writing a new metatarget class that, independently of the other code, figures what files to produce and what commands to use.
However, that would be rather inflexible. For example, adding support for a new compiler would require editing several metatargets. In practice, most files have specific types, and most tools consume and produce files of specific type. To take advantage of this fact, B2 defines concept of target type and generators generators, and has special metatarget class typed-target. Target type is merely an identifier.
It is associated with a set of file extensions that correspond to that type. Generator is an abstraction of a tool. It advertises the types it produces and, if called with a set of input target, tries to construct output targets of the advertised types. Finally, typed-target is associated with specific target type, and relays the generator or generators for that type.
A generator is an instance of a class derived from generator. The generator class itself is suitable for common cases. You can define derived classes for custom scenarios. A much better solution is:. Write the template of the code to be generated, leaving placeholders at the points that will change. First off, B2 has no idea about "verbatim files". So, you must register a new target type. The following code does it:.
The first parameter to type.
0コメント