30
30
<div class="contents topic" id="index">
31
31
<p class="topic-title first">Index</p>
32
32
<ul class="auto-toc simple">
33
<li><a class="reference internal" href="#get-boost" id="id20">1 Get Boost</a></li>
34
<li><a class="reference internal" href="#the-boost-distribution" id="id21">2 The Boost Distribution</a></li>
35
<li><a class="reference internal" href="#header-only-libraries" id="id22">3 Header-Only Libraries</a></li>
36
<li><a class="reference internal" href="#build-a-simple-program-using-boost" id="id23">4 Build a Simple Program Using Boost</a><ul class="auto-toc">
37
<li><a class="reference internal" href="#errors-and-warnings" id="id24">4.1 Errors and Warnings</a></li>
40
<li><a class="reference internal" href="#prepare-to-use-a-boost-library-binary" id="id25">5 Prepare to Use a Boost Library Binary</a><ul class="auto-toc">
41
<li><a class="reference internal" href="#easy-build-and-install" id="id26">5.1 Easy Build and Install</a></li>
42
<li><a class="reference internal" href="#or-build-custom-binaries" id="id27">5.2 Or, Build Custom Binaries</a><ul class="auto-toc">
43
<li><a class="reference internal" href="#get-bjam" id="id28">5.2.1 Get <tt class="docutils literal">bjam</tt></a></li>
44
<li><a class="reference internal" href="#identify-your-toolset" id="id29">5.2.2 Identify Your Toolset</a></li>
45
<li><a class="reference internal" href="#select-a-build-directory" id="id30">5.2.3 Select a Build Directory</a></li>
46
<li><a class="reference internal" href="#invoke-bjam" id="id31">5.2.4 Invoke <tt class="docutils literal">bjam</tt></a></li>
49
<li><a class="reference internal" href="#expected-build-output" id="id32">5.3 Expected Build Output</a></li>
50
<li><a class="reference internal" href="#in-case-of-build-errors" id="id33">5.4 In Case of Build Errors</a></li>
53
<li><a class="reference internal" href="#link-your-program-to-a-boost-library" id="id34">6 Link Your Program to a Boost Library</a><ul class="auto-toc">
54
<li><a class="reference internal" href="#library-naming" id="id35">6.1 Library Naming</a></li>
55
<li><a class="reference internal" href="#test-your-program" id="id36">6.2 Test Your Program</a></li>
58
<li><a class="reference internal" href="#conclusion-and-further-resources" id="id37">7 Conclusion and Further Resources</a></li>
33
<li><a class="reference internal" href="#get-boost" id="id19">1 Get Boost</a></li>
34
<li><a class="reference internal" href="#the-boost-distribution" id="id20">2 The Boost Distribution</a></li>
35
<li><a class="reference internal" href="#header-only-libraries" id="id21">3 Header-Only Libraries</a></li>
36
<li><a class="reference internal" href="#build-a-simple-program-using-boost" id="id22">4 Build a Simple Program Using Boost</a><ul class="auto-toc">
37
<li><a class="reference internal" href="#errors-and-warnings" id="id23">4.1 Errors and Warnings</a></li>
40
<li><a class="reference internal" href="#prepare-to-use-a-boost-library-binary" id="id24">5 Prepare to Use a Boost Library Binary</a><ul class="auto-toc">
41
<li><a class="reference internal" href="#easy-build-and-install" id="id25">5.1 Easy Build and Install</a></li>
42
<li><a class="reference internal" href="#or-build-custom-binaries" id="id26">5.2 Or, Build Custom Binaries</a><ul class="auto-toc">
43
<li><a class="reference internal" href="#install-boost-build" id="id27">5.2.1 Install Boost.Build</a></li>
44
<li><a class="reference internal" href="#identify-your-toolset" id="id28">5.2.2 Identify Your Toolset</a></li>
45
<li><a class="reference internal" href="#select-a-build-directory" id="id29">5.2.3 Select a Build Directory</a></li>
46
<li><a class="reference internal" href="#invoke-bjam" id="id30">5.2.4 Invoke <tt class="docutils literal">bjam</tt></a></li>
49
<li><a class="reference internal" href="#expected-build-output" id="id31">5.3 Expected Build Output</a></li>
50
<li><a class="reference internal" href="#in-case-of-build-errors" id="id32">5.4 In Case of Build Errors</a></li>
53
<li><a class="reference internal" href="#link-your-program-to-a-boost-library" id="id33">6 Link Your Program to a Boost Library</a><ul class="auto-toc">
54
<li><a class="reference internal" href="#library-naming" id="id34">6.1 Library Naming</a></li>
55
<li><a class="reference internal" href="#test-your-program" id="id35">6.2 Test Your Program</a></li>
58
<li><a class="reference internal" href="#conclusion-and-further-resources" id="id36">7 Conclusion and Further Resources</a></li>
61
61
<div class="section" id="get-boost">
62
<h1><a class="toc-backref" href="#id20">1 Get Boost</a></h1>
62
<h1><a class="toc-backref" href="#id19">1 Get Boost</a></h1>
63
63
<p>The most reliable way to get a copy of Boost is to download a
64
distribution from <a class="reference external" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041">SourceForge</a>:</p>
64
distribution from <a class="reference external" href="http://www.boost.org/users/history/version_1_46_1.html">SourceForge</a>:</p>
65
65
<ol class="arabic">
66
<li><p class="first">Download <a class="reference external" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041"><tt class="docutils literal">boost_1_46_0</tt><tt class="docutils literal">.tar.bz2</tt></a>.</p>
66
<li><p class="first">Download <a class="reference external" href="http://www.boost.org/users/history/version_1_46_1.html"><tt class="docutils literal">boost_1_46_1</tt><tt class="docutils literal">.tar.bz2</tt></a>.</p>
68
68
<li><p class="first">In the directory where you want to put the Boost installation,
70
70
<pre class="literal-block">
71
tar --bzip2 -xf <em>/path/to/</em><tt class="docutils literal">boost_1_46_0</tt>.tar.bz2
71
tar --bzip2 -xf <em>/path/to/</em><tt class="docutils literal">boost_1_46_1</tt>.tar.bz2
81
81
reorganize the directory structure of the Boost distribution,
82
82
and/or rename the library binaries.<a class="footnote-reference" href="#packagers" id="id2"><sup>1</sup></a> If you have
83
83
any trouble, we suggest using an official Boost distribution
84
from <a class="reference external" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041">SourceForge</a>.</p>
84
from <a class="reference external" href="http://www.boost.org/users/history/version_1_46_1.html">SourceForge</a>.</p>
86
86
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
87
87
<!-- Software License, Version 1.0. (See accompanying -->
88
88
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
90
90
<div class="section" id="the-boost-distribution">
91
<h1><a class="toc-backref" href="#id21">2 The Boost Distribution</a></h1>
91
<h1><a class="toc-backref" href="#id20">2 The Boost Distribution</a></h1>
92
92
<p>This is a sketch of the resulting directory structure:</p>
93
93
<pre class="literal-block">
94
<strong>boost_1_46_0</strong><strong>/</strong> .................<em>The “boost root directory”</em>
94
<strong>boost_1_46_1</strong><strong>/</strong> .................<em>The “boost root directory”</em>
95
95
<strong>index.htm</strong> .........<em>A copy of www.boost.org starts here</em>
96
96
<strong>boost</strong><strong>/</strong> .........................<em>All Boost Header files</em>
97
97
<tt class="docutils literal"> </tt>
262
262
<div class="section" id="prepare-to-use-a-boost-library-binary">
263
<h1><a class="toc-backref" href="#id25">5 Prepare to Use a Boost Library Binary</a></h1>
263
<h1><a class="toc-backref" href="#id24">5 Prepare to Use a Boost Library Binary</a></h1>
264
264
<p>If you want to use any of the separately-compiled Boost libraries,
265
265
you'll need to acquire library binaries.</p>
266
266
<div class="section" id="easy-build-and-install">
267
<h2><a class="toc-backref" href="#id26">5.1 Easy Build and Install</a></h2>
267
<h2><a class="toc-backref" href="#id25">5.1 Easy Build and Install</a></h2>
268
268
<p>Issue the following commands in the shell (don't type <tt class="docutils literal">$</tt>; that
269
269
represents the shell's prompt):</p>
270
270
<pre class="literal-block">
271
<strong>$</strong> cd <em>path/to/</em><tt class="docutils literal">boost_1_46_0</tt>
271
<strong>$</strong> cd <em>path/to/</em><tt class="docutils literal">boost_1_46_1</tt>
272
272
<strong>$</strong> ./bootstrap.sh --help
274
274
<p>Select your configuration options and invoke <tt class="docutils literal">./bootstrap.sh</tt> again
306
306
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
307
307
<!-- Software License, Version 1.0. (See accompanying -->
308
308
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
309
<div class="section" id="install-boost-build">
310
<h3><a class="toc-backref" href="#id27">5.2.1 Install Boost.Build</a></h3>
309
311
<p><a class="reference external" href="../../tools/build/index.html">Boost.Build</a> is a text-based system for developing, testing, and
310
installing software. To use it, you'll need an executable called
311
<tt class="docutils literal">bjam</tt>.</p>
312
<!-- .. _Boost.Jam documentation: Boost.Jam_ -->
313
<div class="section" id="get-bjam">
314
<h3><a class="toc-backref" href="#id28">5.2.1 Get <tt class="docutils literal">bjam</tt></a></h3>
315
<p><tt class="docutils literal">bjam</tt> is the command-line tool that drives the Boost Build
316
system. To build Boost binaries, you'll invoke <tt class="docutils literal">bjam</tt> from the
318
<p>We suggest you <a class="reference external" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941">download a pre-built <tt class="docutils literal">bjam</tt> executable</a> for your platform.
319
Alternatively, you can build <tt class="docutils literal">bjam</tt> yourself using <a class="reference external" href="../../doc/html/jam/building.html">these
320
instructions</a>.</p>
321
<p>Move the <tt class="docutils literal">bjam</tt> executable into a directory in your PATH. You can
322
see the list of directories in your PATH, separated by colons,
323
by typing “<tt class="docutils literal">echo $PATH</tt>” at the command prompt.</p>
312
installing software. First, you'll need to build and
313
install it. To do this:</p>
314
<ol class="arabic simple">
315
<li>Go to the directory <tt class="docutils literal">tools</tt><tt class="docutils literal">/</tt><tt class="docutils literal">build</tt><tt class="docutils literal">/</tt><tt class="docutils literal">v2</tt><tt class="docutils literal">/</tt>.</li>
316
<li>Run <tt class="docutils literal">bootstrap.bat</tt></li>
317
<li>Run <tt class="docutils literal">bjam install <span class="pre">--prefix=</span></tt><em>PREFIX</em> where <em>PREFIX</em> is
318
the directory where you want Boost.Build to be installed</li>
319
<li>Add <em>PREFIX</em><tt class="docutils literal">/</tt><tt class="docutils literal">bin</tt> to your PATH environment variable.</li>
325
322
<div class="section" id="identify-your-toolset">
326
<span id="toolset-name"></span><span id="toolset"></span><h3><a class="toc-backref" href="#id29">5.2.2 Identify Your Toolset</a></h3>
323
<span id="toolset-name"></span><span id="toolset"></span><h3><a class="toc-backref" href="#id28">5.2.2 Identify Your Toolset</a></h3>
327
324
<p>First, find the toolset corresponding to your compiler in the
328
325
following table (an up-to-date list is always available <a class="reference external" href="http://www.boost.org/boost-build2/doc/html/bbv2/reference/tools.html">in the
329
326
Boost.Build documentation</a>).</p>
330
327
<div class="note">
331
328
<p class="first admonition-title">Note</p>
332
329
<p class="last">If you previously chose a toolset for the purposes of
333
<a class="reference external" href="../../doc/html/jam/building.html">building bjam</a>, you should assume it won't work and instead
330
<a class="reference external" href="../../doc/html/bbv2/installation.html">building bjam</a>, you should assume it won't work and instead
334
331
choose newly from the table below.</p>
336
333
<table border="1" class="docutils">
430
427
purpose in your current working directory.</p>
432
429
<div class="section" id="invoke-bjam">
433
<h3><a class="toc-backref" href="#id31">5.2.4 Invoke <tt class="docutils literal">bjam</tt></a></h3>
430
<h3><a class="toc-backref" href="#id30">5.2.4 Invoke <tt class="docutils literal">bjam</tt></a></h3>
434
431
<p>Change your current directory to the Boost root directory and
435
432
invoke <tt class="docutils literal">bjam</tt> as follows:</p>
436
433
<pre class="literal-block">
437
bjam <strong>--build-dir=</strong><a class="reference internal" href="#id11"><em>build-directory</em></a> <strong>toolset=</strong><a class="reference internal" href="#toolset-name"><em>toolset-name</em></a> <tt class="docutils literal"> </tt> stage
434
bjam <strong>--build-dir=</strong><a class="reference internal" href="#id10"><em>build-directory</em></a> <strong>toolset=</strong><a class="reference internal" href="#toolset-name"><em>toolset-name</em></a> <tt class="docutils literal"> </tt> stage
439
436
<p>For a complete description of these and other invocation options,
440
437
please see the <a class="reference external" href="http://www.boost.org/boost-build2/doc/html/bbv2/advanced/invocation.html">Boost.Build documentation</a>.</p>
441
438
<p>For example, your session might look like this:</p>
442
439
<pre class="literal-block">
443
$ cd ~/<tt class="docutils literal">boost_1_46_0</tt>
440
$ cd ~/<tt class="docutils literal">boost_1_46_1</tt>
444
441
$ bjam <strong>--build-dir=</strong>/tmp/build-boost <strong>toolset=</strong>gcc stage
446
443
<p>That will build static and shared non-debug multi-threaded variants of the libraries. To build all variants, pass the additional option, “<tt class="docutils literal"><span class="pre">--build-type=complete</span></tt>”.</p>
556
553
<ol class="upperalpha">
557
554
<li><p class="first">You can specify the full path to each library:</p>
558
555
<pre class="literal-block">
559
$ c++ -I <em>path/to/</em><tt class="docutils literal">boost_1_46_0</tt> example.cpp -o example <strong>\</strong>
556
$ c++ -I <em>path/to/</em><tt class="docutils literal">boost_1_46_1</tt> example.cpp -o example <strong>\</strong>
560
557
<strong>~/boost/stage/lib/libboost_regex-gcc34-mt-d-1_36.a</strong>
563
<li><p class="first">You can separately specify a directory to search (with <tt class="docutils literal"><span class="pre">-L</span></tt><em>directory</em>) and a library name to search for (with <tt class="docutils literal"><span class="pre">-l</span></tt><em>library</em>,<a class="footnote-reference" href="#lowercase-l" id="id15"><sup>2</sup></a> dropping the filename's leading <tt class="docutils literal">lib</tt> and trailing
560
<li><p class="first">You can separately specify a directory to search (with <tt class="docutils literal"><span class="pre">-L</span></tt><em>directory</em>) and a library name to search for (with <tt class="docutils literal"><span class="pre">-l</span></tt><em>library</em>,<a class="footnote-reference" href="#lowercase-l" id="id14"><sup>2</sup></a> dropping the filename's leading <tt class="docutils literal">lib</tt> and trailing
564
561
suffix (<tt class="docutils literal">.a</tt> in this case):</p>
565
562
<pre class="literal-block">
566
$ c++ -I <em>path/to/</em><tt class="docutils literal">boost_1_46_0</tt> example.cpp -o example <strong>\</strong>
563
$ c++ -I <em>path/to/</em><tt class="docutils literal">boost_1_46_1</tt> example.cpp -o example <strong>\</strong>
567
564
<strong>-L~/boost/stage/lib/ -lboost_regex-gcc34-mt-d-1_36</strong>
569
566
<p>As you can see, this method is just as terse as method A for one