In this section, we will outline the steps necessary to achieve that. We will use the build tool that comes bundled with every boost distribution: bjam. Note Building without bjam Besides bjam, there are of course other ways to get your module built. There are of course other build tools apart from bjam. Take note however that the preferred build tool for Boost.
|Published (Last):||13 July 2010|
|PDF File Size:||9.63 Mb|
|ePub File Size:||4.50 Mb|
|Price:||Free* [*Free Regsitration Required]|
This section will guide you though the most basic features of Boost. Build V2. Hello, world The simplest project that Boost. The project is described by a file called Jamroot that contains: exe hello : hello. First of all, just invoking bjam will build the hello executable by compiling and linking hello. By default, debug variant is built. Now, to build the release variant of hello, invoke bjam release Note that debug and release variants are created in different directories, so you can switch between variants or even build multiple variants at once, without any unnecessary recompilation.
Since we have already built both variants of hello, hello. Now let us remove all the built products: bjam --clean debug release It is also possible to build or clean specific targets. The following two commands, respectively, build or clean only the debug version of hello2.
Build uses features with associated values. For example, the debug-symbols feature can have a value of on or off. A property is just a feature, value pair. When a user initiates a build, Boost. Build automatically translates the requested properties into appropriate command-line flags for invoking toolset components like compilers and linkers.
There are many built-in features that can be combined to produce arbitrary build configurations. Build will deduce the its identity just from the name of one of its values. Build Requests and Target Requirements The set of properties specified on the command line constitute a build request—a description of the desired properties for building the requested targets or, if no targets were explicitly requested, the project in the current directory.
For example, the locations of included header files are normally not specified on the command-line, but described in Jamfiles as target requirements and automatically combined with the build request for those targets. Multithread-enabled compilation is another example of a typical target requirement. The Jamfile fragment below illustrates how these requirements might be specified. Project Attributes If we want the same requirements for our other target, hello2 , we could simply duplicate them.
However, as projects grow, that approach leads to a great deal of repeated boilerplate in Jamfiles. Project Hierarchies So far we have only considered examples with one project —a. Jam file, Jamroot. A typical large codebase would be composed of many projects organized into a tree.
The top of the tree is called the project root. Every subproject is defined by a file called Jamfile in a descendant directory of the project root. The parent project of a subproject is defined by the nearest Jamfile or Jamroot file in an ancestor directory. Inherited requirements are combined with any requirements specified by the subproject. Of course, any project can add include paths to those specified by its parents.
Invoking bjam without explicitly specifying any targets on the command line builds the project rooted in the current directory. Dependent Targets When a building a target X depends on first building another target Y such as a library that must be linked with X , Y is called a dependency of X and X is termed a dependent of Y.
Tip Some other build system have special syntax for listing dependent libraries, for example LIBS variable. In Boost. Build, you just add the library to the list of sources. The answer is that some features are propagated—Boost. Build attempts to use dependencies with the same value of propagated features. The library probably has some headers that must be used when compiling app. Another improvement is using symbolic identifiers to refer to the library, as opposed to Jamfile location.
In a large project, a library can be used by many targets, and if they all use Jamfile location, a change in directory organization entails much work. The solution is to use project ids—symbolic names not tied to directory layout. Note that project ids are global—two Jamfiles are not allowed to assign the same project id to different directories. Build can create and use both kinds. The kind of library produced from a lib target is determined by the value of the link feature.
Default value is shared, and to build a static library, the value should be static. If that library is used by many targets, you could use target references everywhere: exe e1 : e1.
A better approach is to introduce a level of indirection. Tip When one library uses another, you put the second library in the source list of the first. For example: lib utils : utils. When core is built as a shared library, it is linked directly into utils. This restriction is lifted when you use Boost.
Build testing facilities—the PATH variable will be automatically adjusted before running the executable. This can be achieved using conditional requirements. Sometimes the ways a target is built are so different that describing them using conditional requirements would be hard. For example, imagine that a library actually uses different source files depending on the toolset used to build it. Build will compare requirements for each alternative with build properties to find the best match.
In all other cases, the most generic alternative 1 will be built. Target alternatives can be used to associate multiple library files with a single conceptual target. Naturally, there are no sources. Once a prebuilt target has been declared, it can be used just like any other target: exe app : app. If the gcc toolset were used to link an executable target to pythonlib, -lpython22 would appear in the command line other compilers may use different options.
Subscribe to RSS
This section will guide you though the most basic features of Boost. Build V2. Hello, world The simplest project that Boost. The project is described by a file called Jamroot that contains: exe hello : hello. First of all, just invoking bjam will build the hello executable by compiling and linking hello.
BJAM TUTORIAL PDF
In this section, we shall outline the steps necessary to achieve that. We shall use the build tool that comes bundled with every boost distribution: bjam. Building without bjam Besides bjam, there are of course other ways to get your module built. There are of course other build tools apart from bjam. Take note however that the preferred build tool for Boost. Python is bjam. There are so many ways to set up the build incorrectly.
Building without bjam Besides bjam, there are of course other ways to get your module built. There are so many ways to set up the build incorrectly. Introduction — Installation Now, to build the release variant of helloinvoke. For example, to build an executable from the source files listed in Examplecreate a file named Jamroot in the directory hellobeatles as shown in Example This can be achieved with conditional requirements.