1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Chapter 23. Tutorial</title> |
---|
5 | <link rel="stylesheet" href="../boostbook.css" type="text/css"> |
---|
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
---|
7 | <style type="text/css"> |
---|
8 | body { background-image: url('http://docbook.sourceforge.net/release/images/draft.png'); |
---|
9 | background-repeat: no-repeat; |
---|
10 | background-position: top left; |
---|
11 | /* The following properties make the watermark "fixed" on the page. */ |
---|
12 | /* I think that's just a bit too distracting for the reader... */ |
---|
13 | /* background-attachment: fixed; */ |
---|
14 | /* background-position: center center; */ |
---|
15 | }</style> |
---|
16 | <link rel="start" href="../index.html" title="The Boost C++ Libraries"> |
---|
17 | <link rel="up" href="../bbv2.html" title="Part III. Boost.Build v2 User Manual"> |
---|
18 | <link rel="prev" href="installation.html" title="Chapter 22. Installation"> |
---|
19 | <link rel="next" href="tutorial/properties.html" title="Properties"> |
---|
20 | </head> |
---|
21 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
22 | <table cellpadding="2" width="100%"> |
---|
23 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../boost.png"></td> |
---|
24 | <td align="center"><a href="../../../index.htm">Home</a></td> |
---|
25 | <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> |
---|
26 | <td align="center"><a href="../../../people/people.htm">People</a></td> |
---|
27 | <td align="center"><a href="../../../more/faq.htm">FAQ</a></td> |
---|
28 | <td align="center"><a href="../../../more/index.htm">More</a></td> |
---|
29 | </table> |
---|
30 | <hr> |
---|
31 | <div class="spirit-nav"> |
---|
32 | <a accesskey="p" href="installation.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../bbv2.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="tutorial/properties.html"><img src="../images/next.png" alt="Next"></a> |
---|
33 | </div> |
---|
34 | <div class="chapter" lang="en"> |
---|
35 | <div class="titlepage"><div><div><h2 class="title"> |
---|
36 | <a name="bbv2.tutorial"></a>Chapter 23. Tutorial</h2></div></div></div> |
---|
37 | <div class="toc"> |
---|
38 | <p><b>Table of Contents</b></p> |
---|
39 | <dl> |
---|
40 | <dt><span class="section"><a href="tutorial.html#bbv2.tutorial.hello">Hello, world</a></span></dt> |
---|
41 | <dt><span class="section"><a href="tutorial/properties.html">Properties</a></span></dt> |
---|
42 | <dd><dl> |
---|
43 | <dt><span class="section"><a href="tutorial/properties.html#bbv2.tutorial.properties.requirements">Build Requests and Target Requirements</a></span></dt> |
---|
44 | <dt><span class="section"><a href="tutorial/properties.html#bbv2.tutorial.properties.project_attributes">Project Attributes</a></span></dt> |
---|
45 | </dl></dd> |
---|
46 | <dt><span class="section"><a href="tutorial/hierarchy.html">Project Hierarchies</a></span></dt> |
---|
47 | <dt><span class="section"><a href="tutorial/libs.html">Dependent Targets</a></span></dt> |
---|
48 | <dt><span class="section"><a href="tutorial/linkage.html">Static and shared libaries</a></span></dt> |
---|
49 | <dt><span class="section"><a href="tutorial/conditions.html">Conditions and alternatives</a></span></dt> |
---|
50 | <dt><span class="section"><a href="tutorial/prebuilt.html">Prebuilt targets</a></span></dt> |
---|
51 | </dl> |
---|
52 | </div> |
---|
53 | <div class="section" lang="en"> |
---|
54 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
---|
55 | <a name="bbv2.tutorial.hello"></a>Hello, world</h2></div></div></div> |
---|
56 | <p>The simplest project that Boost.Build can construct is |
---|
57 | stored in <code class="filename">example/hello/</code> directory. The |
---|
58 | project is described by a file |
---|
59 | called <code class="filename">Jamroot</code> that contains: |
---|
60 | |
---|
61 | </p> |
---|
62 | <pre class="programlisting"> |
---|
63 | exe hello : hello.cpp ; |
---|
64 | </pre> |
---|
65 | <p> |
---|
66 | |
---|
67 | Even with this simple setup, you can do some interesting |
---|
68 | things. First of all, just invoking <span><strong class="command">bjam</strong></span> will |
---|
69 | build the <code class="filename">hello</code> |
---|
70 | executable by compiling and |
---|
71 | linking <code class="filename">hello.cpp</code>. By default, debug variant |
---|
72 | is built. Now, to build the |
---|
73 | release variant of <code class="filename">hello</code>, invoke |
---|
74 | |
---|
75 | </p> |
---|
76 | <pre class="screen"> |
---|
77 | bjam release |
---|
78 | </pre> |
---|
79 | <p> |
---|
80 | |
---|
81 | Note that debug and release variants are created in different |
---|
82 | directories, so you can switch between variants or even build |
---|
83 | multiple variants at once, without any unnecessary |
---|
84 | recompilation. Let's extend the example by adding another line |
---|
85 | to our project's <code class="filename">Jamroot</code>: |
---|
86 | |
---|
87 | </p> |
---|
88 | <pre class="programlisting"> |
---|
89 | exe hello2 : hello.cpp ; |
---|
90 | </pre> |
---|
91 | <p> |
---|
92 | |
---|
93 | Now let us build both the debug and release variants of our project |
---|
94 | again: |
---|
95 | |
---|
96 | </p> |
---|
97 | <pre class="screen"> |
---|
98 | bjam debug release |
---|
99 | </pre> |
---|
100 | <p> |
---|
101 | |
---|
102 | Note that two variants of <code class="filename">hello2</code> are linked. |
---|
103 | Since we have already built both variants |
---|
104 | of <code class="filename">hello</code>, hello.cpp won't be recompiled; |
---|
105 | instead the existing object files will just be linked into the |
---|
106 | corresponding variants of <code class="filename">hello2</code>. Now |
---|
107 | let's remove all the built products: |
---|
108 | |
---|
109 | </p> |
---|
110 | <pre class="screen"> |
---|
111 | bjam --clean debug release |
---|
112 | </pre> |
---|
113 | <p> |
---|
114 | |
---|
115 | It's also possible to build or clean specific targets. The |
---|
116 | following two commands, respectively, build or clean only the |
---|
117 | debug version of <code class="filename">hello2</code>. |
---|
118 | |
---|
119 | </p> |
---|
120 | <pre class="screen"> |
---|
121 | bjam hello2 |
---|
122 | bjam --clean hello2 |
---|
123 | </pre> |
---|
124 | </div> |
---|
125 | </div> |
---|
126 | <table width="100%"><tr> |
---|
127 | <td align="left"></td> |
---|
128 | <td align="right"><small></small></td> |
---|
129 | </tr></table> |
---|
130 | <hr> |
---|
131 | <div class="spirit-nav"> |
---|
132 | <a accesskey="p" href="installation.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../bbv2.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="tutorial/properties.html"><img src="../images/next.png" alt="Next"></a> |
---|
133 | </div> |
---|
134 | </body> |
---|
135 | </html> |
---|