1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Build</title> |
---|
5 | <link rel="stylesheet" href="../boostbook.css" type="text/css"> |
---|
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.68.1"> |
---|
7 | <link rel="start" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> |
---|
8 | <link rel="up" href="../thread.html" title="Chapter 15. Boost.Thread"> |
---|
9 | <link rel="prev" href="configuration.html" title="Configuration"> |
---|
10 | <link rel="next" href="implementation_notes.html" title="Implementation Notes"> |
---|
11 | </head> |
---|
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
13 | <table cellpadding="2" width="100%"> |
---|
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> |
---|
15 | <td align="center"><a href="../../../index.htm">Home</a></td> |
---|
16 | <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> |
---|
17 | <td align="center"><a href="../../../people/people.htm">People</a></td> |
---|
18 | <td align="center"><a href="../../../more/faq.htm">FAQ</a></td> |
---|
19 | <td align="center"><a href="../../../more/index.htm">More</a></td> |
---|
20 | </table> |
---|
21 | <hr> |
---|
22 | <div class="spirit-nav"> |
---|
23 | <a accesskey="p" href="configuration.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread.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="implementation_notes.html"><img src="../images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="section" lang="en"> |
---|
26 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
---|
27 | <a name="thread.build"></a>Build</h2></div></div></div> |
---|
28 | <div class="toc"><dl> |
---|
29 | <dt><span class="section"><a href="build.html#thread.build.building">Building the <span class="bold"><strong>Boost.Thread</strong></span> Libraries</a></span></dt> |
---|
30 | <dt><span class="section"><a href="build.html#thread.build.testing">Testing the <span class="bold"><strong>Boost.Thread</strong></span> Libraries</a></span></dt> |
---|
31 | </dl></div> |
---|
32 | <p> |
---|
33 | How you build the <span class="bold"><strong>Boost.Thread</strong></span> libraries, and how you build your own applications |
---|
34 | that use those libraries, are some of the most frequently asked questions. Build |
---|
35 | processes are difficult to deal with in a portable manner. That's one reason |
---|
36 | why <span class="bold"><strong>Boost.Thread</strong></span> makes use of <span class="bold"><strong>Boost.Build</strong></span>. |
---|
37 | In general you should refer to the documentation for <span class="bold"><strong>Boost.Build</strong></span>. |
---|
38 | This document will only supply you with some simple usage examples for how to |
---|
39 | use <span class="emphasis"><em>bjam</em></span> to build and test <span class="bold"><strong>Boost.Thread</strong></span>. In addition, this document |
---|
40 | will try to explain the build requirements so that users may create their own |
---|
41 | build processes (for instance, create an IDE specific project), both for building |
---|
42 | and testing <span class="bold"><strong>Boost.Thread</strong></span>, as well as for building their own projects using |
---|
43 | <span class="bold"><strong>Boost.Thread</strong></span>. |
---|
44 | </p> |
---|
45 | <div class="section" lang="en"> |
---|
46 | <div class="titlepage"><div><div><h3 class="title"> |
---|
47 | <a name="thread.build.building"></a>Building the <span class="bold"><strong>Boost.Thread</strong></span> Libraries</h3></div></div></div> |
---|
48 | <div class="toc"><dl> |
---|
49 | <dt><span class="section"><a href="build.html#thread.build.precompiled">Precompiled</a></span></dt> |
---|
50 | <dt><span class="section"><a href="build.html#thread.build.bjam"><span class="bold"><strong>Boost.Build</strong></span> Project</a></span></dt> |
---|
51 | <dt><span class="section"><a href="build.html#thread.build.source">Source Form</a></span></dt> |
---|
52 | </dl></div> |
---|
53 | <p> |
---|
54 | Building the <span class="bold"><strong>Boost.Thread</strong></span> Library depends on how you intend to use it. You have several options: |
---|
55 | </p> |
---|
56 | <div class="itemizedlist"><ul type="disc"> |
---|
57 | <li> |
---|
58 | Using as a <a href="build.html#thread.build.precompiled" title="Precompiled">precompiled</a> library, possibly |
---|
59 | with auto-linking, or for use from within an IDE. |
---|
60 | </li> |
---|
61 | <li> |
---|
62 | Use from a <a href="build.html#thread.build.bjam" title="Boost.Build Project"><span class="bold"><strong>Boost.Build</strong></span></a> project. |
---|
63 | </li> |
---|
64 | <li> |
---|
65 | Using in <a href="build.html#thread.build.source" title="Source Form">source</a> form. |
---|
66 | </li> |
---|
67 | </ul></div> |
---|
68 | <p> |
---|
69 | </p> |
---|
70 | <div class="section" lang="en"> |
---|
71 | <div class="titlepage"><div><div><h4 class="title"> |
---|
72 | <a name="thread.build.precompiled"></a>Precompiled</h4></div></div></div> |
---|
73 | <p> |
---|
74 | Using the <span class="bold"><strong>Boost.Thread</strong></span> library in precompiled form is the way to go if you want to |
---|
75 | install the library to a standard place, from where your linker is able to resolve code |
---|
76 | in binary form. You also will want this option if compile time is a concern. Multiple |
---|
77 | variants are available, for different toolsets and build variants (debug/release). |
---|
78 | The library files are named <span class="emphasis"><em>{lead}boost_thread{build-specific-tags}.{extension}</em></span>, |
---|
79 | where the build-specific-tags indicate the toolset used to build the library, whether it's |
---|
80 | a debug or release build, what version of <span class="bold"><strong>Boost</strong></span> was used, etc.; and the lead and extension |
---|
81 | are the appropriate extensions for a dynamic link library or static library for the platform |
---|
82 | for which <span class="bold"><strong>Boost.Thread</strong></span> is being built. |
---|
83 | For instance, a debug build of the dynamic library built for Win32 with VC++ 7.1 using Boost 1.34 would |
---|
84 | be named <span class="emphasis"><em>boost_thread-vc71-mt-gd-1_34.dll</em></span>. |
---|
85 | More information on this should be available from the <span class="bold"><strong>Boost.Build</strong></span> documentation. |
---|
86 | </p> |
---|
87 | <p> |
---|
88 | Building should be possible with the default configuration. If you are running into problems, |
---|
89 | it might be wise to adjust your local settings of <span class="bold"><strong>Boost.Build</strong></span> though. Typically you will |
---|
90 | need to get your user-config.jam file to reflect your environment, i.e. used toolsets. Please |
---|
91 | refer to the <span class="bold"><strong>Boost.Build</strong></span> documentation to learn how to do this. |
---|
92 | </p> |
---|
93 | <p> |
---|
94 | To create the libraries you need to open a command shell and change to the |
---|
95 | <span class="emphasis"><em>boost_root</em></span> directory. From there you give the command |
---|
96 | </p> |
---|
97 | <pre class="programlisting">bjam --toolset=<span class="emphasis"><em>mytoolset</em></span> stage --with-thread</pre> |
---|
98 | <p> |
---|
99 | Replace <span class="emphasis"><em>mytoolset</em></span> with the name of your toolset, e.g. msvc-7.1 . |
---|
100 | This will compile and put the libraries into the <span class="emphasis"><em>stage</em></span> directory which is just below the |
---|
101 | <span class="emphasis"><em>boost_root</em></span> directory. <span class="bold"><strong>Boost.Build</strong></span> by default will generate static and |
---|
102 | dynamic variants for debug and release. |
---|
103 | </p> |
---|
104 | <div class="note"><table border="0" summary="Note"> |
---|
105 | <tr> |
---|
106 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td> |
---|
107 | <th align="left">Note</th> |
---|
108 | </tr> |
---|
109 | <tr><td align="left" valign="top"> |
---|
110 | Invoking the above command without the --with-thread switch <span class="bold"><strong>Boost.Build</strong></span> will build all of |
---|
111 | the Boost distribution, including <span class="bold"><strong>Boost.Thread</strong></span>. |
---|
112 | </td></tr> |
---|
113 | </table></div> |
---|
114 | <p> |
---|
115 | The next step is to copy your libraries to a place where your linker is able to pick them up. |
---|
116 | It is also quite possible to leave them in the stage directory and instruct your IDE to take them |
---|
117 | from there. |
---|
118 | </p> |
---|
119 | <p> |
---|
120 | In your IDE you then need to add <span class="emphasis"><em>boost_root</em></span>/boost to the paths where the compiler |
---|
121 | expects to find files to be included. For toolsets that support <span class="emphasis"><em>auto-linking</em></span> |
---|
122 | it is not necessary to explicitly specify the name of the library to link against, it is sufficient |
---|
123 | to specify the path of the stage directory. Typically this is true on Windows. For gcc you need |
---|
124 | to specify the exact library name (including all the tags). Please don't forget that threading |
---|
125 | support must be turned on to be able to use the library. You should be able now to build your |
---|
126 | project from the IDE. |
---|
127 | </p> |
---|
128 | </div> |
---|
129 | <div class="section" lang="en"> |
---|
130 | <div class="titlepage"><div><div><h4 class="title"> |
---|
131 | <a name="thread.build.bjam"></a><span class="bold"><strong>Boost.Build</strong></span> Project</h4></div></div></div> |
---|
132 | <p> |
---|
133 | If you have decided to use <span class="bold"><strong>Boost.Build</strong></span> as a build environment for your application, you simply |
---|
134 | need to add a single line to your <span class="emphasis"><em>Jamroot</em></span> file: |
---|
135 | </p> |
---|
136 | <pre class="programlisting">use-project /boost : {path-to-boost-root} ;</pre> |
---|
137 | <p> |
---|
138 | where <span class="emphasis"><em>{path-to-boost-root}</em></span> needs to be replaced with the location of |
---|
139 | your copy of the boost tree. |
---|
140 | Later when you specify a component that needs to link against <span class="bold"><strong>Boost.Thread</strong></span> you specify this |
---|
141 | as e.g.: |
---|
142 | </p> |
---|
143 | <pre class="programlisting">exe myapp : {myappsources} /boost//thread ;</pre> |
---|
144 | <p> |
---|
145 | and you are done. |
---|
146 | </p> |
---|
147 | </div> |
---|
148 | <div class="section" lang="en"> |
---|
149 | <div class="titlepage"><div><div><h4 class="title"> |
---|
150 | <a name="thread.build.source"></a>Source Form</h4></div></div></div> |
---|
151 | <p> |
---|
152 | Of course it is also possible to use the <span class="bold"><strong>Boost.Thread</strong></span> library in source form. |
---|
153 | First you need to specify the <span class="emphasis"><em>boost_root</em></span>/boost directory as |
---|
154 | a path where your compiler expects to find files to include. It is not easy |
---|
155 | to isolate the <span class="bold"><strong>Boost.Thread</strong></span> include files from the rest of the boost |
---|
156 | library though. You would also need to isolate every include file that the thread |
---|
157 | library depends on. Next you need to copy the files from |
---|
158 | <span class="emphasis"><em>boost_root</em></span>/libs/thread/src to your project and instruct your |
---|
159 | build system to compile them together with your project. Please look into the |
---|
160 | <span class="emphasis"><em>Jamfile</em></span> in <span class="emphasis"><em>boost_root</em></span>/libs/thread/build |
---|
161 | to find out which compiler options and defines you will need to get a clean compile. |
---|
162 | Using the boost library in this way is the least recommended, and should only be |
---|
163 | considered if avoiding dependency on <span class="bold"><strong>Boost.Build</strong></span> is a requirement. Even if so |
---|
164 | it might be a better option to use the library in it's precompiled form. |
---|
165 | Precompiled downloads are available from the boost consulting web site, or as |
---|
166 | part of most linux distributions. |
---|
167 | </p> |
---|
168 | </div> |
---|
169 | </div> |
---|
170 | <div class="section" lang="en"> |
---|
171 | <div class="titlepage"><div><div><h3 class="title"> |
---|
172 | <a name="thread.build.testing"></a>Testing the <span class="bold"><strong>Boost.Thread</strong></span> Libraries</h3></div></div></div> |
---|
173 | <p> |
---|
174 | To test the <span class="bold"><strong>Boost.Thread</strong></span> libraries using <span class="bold"><strong>Boost.Build</strong></span>, simply change to the |
---|
175 | directory <span class="emphasis"><em>boost_root</em></span>/libs/thread/test and execute the command: |
---|
176 | </p> |
---|
177 | <pre class="programlisting">bjam --toolset=<span class="emphasis"><em>mytoolset</em></span> test</pre> |
---|
178 | <p> |
---|
179 | </p> |
---|
180 | </div> |
---|
181 | </div> |
---|
182 | <table width="100%"><tr> |
---|
183 | <td align="left"><small><p>Last revised: January 18, 2007 at 17:33:50 GMT</p></small></td> |
---|
184 | <td align="right"><small>Copyright © 2001-2003 William E. Kempf</small></td> |
---|
185 | </tr></table> |
---|
186 | <hr> |
---|
187 | <div class="spirit-nav"> |
---|
188 | <a accesskey="p" href="configuration.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread.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="implementation_notes.html"><img src="../images/next.png" alt="Next"></a> |
---|
189 | </div> |
---|
190 | </body> |
---|
191 | </html> |
---|