1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter3.Tutorial</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="../index.html" title="Boost.Build V2 User Manual">
<link rel="up" href="../index.html" title="Boost.Build V2 User Manual">
<link rel="prev" href="installation.html" title="Chapter2.Installation">
<link rel="next" href="tutorial/properties.html" title="Properties">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="installation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial/properties.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="chapter" lang="en">
<div class="titlepage"><div><div><h2 class="title">
<a name="bbv2.tutorial"></a>Chapter3.Tutorial</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="tutorial.html#bbv2.tutorial.hello">Hello, world</a></span></dt>
<dt><span class="section"><a href="tutorial/properties.html">Properties</a></span></dt>
<dt><span class="section"><a href="tutorial/hierarchy.html">Project Hierarchies</a></span></dt>
<dt><span class="section"><a href="tutorial/libs.html">Dependent Targets</a></span></dt>
<dt><span class="section"><a href="tutorial/testing.html">Testing</a></span></dt>
<dt><span class="section"><a href="tutorial/linkage.html">Static and shared libaries</a></span></dt>
<dt><span class="section"><a href="tutorial/conditions.html">Conditions and alternatives</a></span></dt>
<dt><span class="section"><a href="tutorial/prebuilt.html">Prebuilt targets</a></span></dt>
</dl>
</div>
<p>This section will guide you though the most basic features of
Boost.Build V2. We will start with the “Hello, world” example,
learn how to use libraries, and finish with testing and installing features.
</p>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="bbv2.tutorial.hello"></a>Hello, world</h2></div></div></div>
<p>The simplest project that Boost.Build can construct is
stored in <code class="filename">example/hello/</code> directory. The
project is described by a file
called <code class="filename">Jamroot</code> that contains:
</p>
<pre class="programlisting">
exe hello : hello.cpp ;
</pre>
<p>
Even with this simple setup, you can do some interesting
things. First of all, just invoking <span><strong class="command">bjam</strong></span> will
build the <code class="filename">hello</code>
executable by compiling and
linking <code class="filename">hello.cpp</code>. By default, debug variant
is built. Now, to build the
release variant of <code class="filename">hello</code>, invoke
</p>
<pre class="screen">
bjam release
</pre>
<p>
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. Let's extend the example by adding another line
to our project's <code class="filename">Jamroot</code>:
</p>
<pre class="programlisting">
exe hello2 : hello.cpp ;
</pre>
<p>
Now let us build both the debug and release variants of our project
again:
</p>
<pre class="screen">
bjam debug release
</pre>
<p>
Note that two variants of <code class="filename">hello2</code> are linked.
Since we have already built both variants
of <code class="filename">hello</code>, hello.cpp won't be recompiled;
instead the existing object files will just be linked into the
corresponding variants of <code class="filename">hello2</code>. Now
let's remove all the built products:
</p>
<pre class="screen">
bjam --clean debug release
</pre>
<p>
It's also possible to build or clean specific targets. The
following two commands, respectively, build or clean only the
debug version of <code class="filename">hello2</code>.
</p>
<pre class="screen">
bjam hello2
bjam --clean hello2
</pre>
<p>
</p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small></small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="installation.html"><img src="../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial/properties.html"><img src="../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
|