26
26
<div class="contents topic" id="index">
27
27
<p class="topic-title first">Index</p>
28
28
<ul class="auto-toc simple">
29
<li><a class="reference internal" href="#get-boost" id="id29">1 Get Boost</a></li>
30
<li><a class="reference internal" href="#the-boost-distribution" id="id30">2 The Boost Distribution</a></li>
31
<li><a class="reference internal" href="#header-only-libraries" id="id31">3 Header-Only Libraries</a></li>
32
<li><a class="reference internal" href="#build-a-simple-program-using-boost" id="id32">4 Build a Simple Program Using Boost</a><ul class="auto-toc">
33
<li><a class="reference internal" href="#build-from-the-visual-studio-ide" id="id33">4.1 Build From the Visual Studio IDE</a></li>
34
<li><a class="reference internal" href="#or-build-from-the-command-prompt" id="id34">4.2 Or, Build From the Command Prompt</a></li>
35
<li><a class="reference internal" href="#errors-and-warnings" id="id35">4.3 Errors and Warnings</a></li>
38
<li><a class="reference internal" href="#prepare-to-use-a-boost-library-binary" id="id36">5 Prepare to Use a Boost Library Binary</a><ul class="auto-toc">
39
<li><a class="reference internal" href="#install-visual-studio-binaries" id="id37">5.1 Install Visual Studio Binaries</a></li>
40
<li><a class="reference internal" href="#or-simplified-build-from-source" id="id38">5.2 Or, Simplified Build From Source</a></li>
41
<li><a class="reference internal" href="#or-build-binaries-from-source" id="id39">5.3 Or, Build Binaries From Source</a><ul class="auto-toc">
42
<li><a class="reference internal" href="#get-bjam" id="id40">5.3.1 Get <tt class="docutils literal">bjam</tt></a></li>
43
<li><a class="reference internal" href="#identify-your-toolset" id="id41">5.3.2 Identify Your Toolset</a></li>
44
<li><a class="reference internal" href="#select-a-build-directory" id="id42">5.3.3 Select a Build Directory</a></li>
45
<li><a class="reference internal" href="#invoke-bjam" id="id43">5.3.4 Invoke <tt class="docutils literal">bjam</tt></a></li>
48
<li><a class="reference internal" href="#expected-build-output" id="id44">5.4 Expected Build Output</a></li>
49
<li><a class="reference internal" href="#in-case-of-build-errors" id="id45">5.5 In Case of Build Errors</a></li>
52
<li><a class="reference internal" href="#link-your-program-to-a-boost-library" id="id46">6 Link Your Program to a Boost Library</a><ul class="auto-toc">
53
<li><a class="reference internal" href="#link-from-within-the-visual-studio-ide" id="id47">6.1 Link From Within the Visual Studio IDE</a></li>
54
<li><a class="reference internal" href="#or-link-from-the-command-prompt" id="id48">6.2 Or, Link From the Command Prompt</a></li>
55
<li><a class="reference internal" href="#library-naming" id="id49">6.3 Library Naming</a></li>
56
<li><a class="reference internal" href="#test-your-program" id="id50">6.4 Test Your Program</a></li>
59
<li><a class="reference internal" href="#conclusion-and-further-resources" id="id51">7 Conclusion and Further Resources</a></li>
29
<li><a class="reference internal" href="#get-boost" id="id28">1 Get Boost</a></li>
30
<li><a class="reference internal" href="#the-boost-distribution" id="id29">2 The Boost Distribution</a></li>
31
<li><a class="reference internal" href="#header-only-libraries" id="id30">3 Header-Only Libraries</a></li>
32
<li><a class="reference internal" href="#build-a-simple-program-using-boost" id="id31">4 Build a Simple Program Using Boost</a><ul class="auto-toc">
33
<li><a class="reference internal" href="#build-from-the-visual-studio-ide" id="id32">4.1 Build From the Visual Studio IDE</a></li>
34
<li><a class="reference internal" href="#or-build-from-the-command-prompt" id="id33">4.2 Or, Build From the Command Prompt</a></li>
35
<li><a class="reference internal" href="#errors-and-warnings" id="id34">4.3 Errors and Warnings</a></li>
38
<li><a class="reference internal" href="#prepare-to-use-a-boost-library-binary" id="id35">5 Prepare to Use a Boost Library Binary</a><ul class="auto-toc">
39
<li><a class="reference internal" href="#install-visual-studio-binaries" id="id36">5.1 Install Visual Studio Binaries</a></li>
40
<li><a class="reference internal" href="#or-simplified-build-from-source" id="id37">5.2 Or, Simplified Build From Source</a></li>
41
<li><a class="reference internal" href="#or-build-binaries-from-source" id="id38">5.3 Or, Build Binaries From Source</a><ul class="auto-toc">
42
<li><a class="reference internal" href="#install-boost-build" id="id39">5.3.1 Install Boost.Build</a></li>
43
<li><a class="reference internal" href="#identify-your-toolset" id="id40">5.3.2 Identify Your Toolset</a></li>
44
<li><a class="reference internal" href="#select-a-build-directory" id="id41">5.3.3 Select a Build Directory</a></li>
45
<li><a class="reference internal" href="#invoke-bjam" id="id42">5.3.4 Invoke <tt class="docutils literal">bjam</tt></a></li>
48
<li><a class="reference internal" href="#expected-build-output" id="id43">5.4 Expected Build Output</a></li>
49
<li><a class="reference internal" href="#in-case-of-build-errors" id="id44">5.5 In Case of Build Errors</a></li>
52
<li><a class="reference internal" href="#link-your-program-to-a-boost-library" id="id45">6 Link Your Program to a Boost Library</a><ul class="auto-toc">
53
<li><a class="reference internal" href="#link-from-within-the-visual-studio-ide" id="id46">6.1 Link From Within the Visual Studio IDE</a></li>
54
<li><a class="reference internal" href="#or-link-from-the-command-prompt" id="id47">6.2 Or, Link From the Command Prompt</a></li>
55
<li><a class="reference internal" href="#library-naming" id="id48">6.3 Library Naming</a></li>
56
<li><a class="reference internal" href="#test-your-program" id="id49">6.4 Test Your Program</a></li>
59
<li><a class="reference internal" href="#conclusion-and-further-resources" id="id50">7 Conclusion and Further Resources</a></li>
62
62
<div class="section" id="get-boost">
63
<h1><a class="toc-backref" href="#id29">1 Get Boost</a></h1>
63
<h1><a class="toc-backref" href="#id28">1 Get Boost</a></h1>
64
64
<p>The easiest way to get a copy of Boost is to use an installer. The
65
<a class="reference external" href="http://www.boost.org/doc/libs/1_36_0/more/getting_started/index.html">Boost website version of this Getting Started guide</a> will have
65
<a class="reference external" href="http://www.boost.org/more/getting_started/index.html">Boost website version of this Getting Started guide</a> will have
66
66
undated information on installers as they become available, or see
67
<a class="reference external" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041">Boost downloads</a> or the <a class="reference external" href="http://www.boostpro.com/products/free">installer</a> provided by <a class="reference external" href="http://www.boostpro.com">BoostPro
67
<a class="reference external" href="http://www.boost.org/users/history/version_1_46_1.html">Boost downloads</a> or the <a class="reference external" href="http://www.boostpro.com/products/free">installer</a> provided by <a class="reference external" href="http://www.boostpro.com">BoostPro
68
68
Computing</a>. We especially recommend using an installer if you use
69
69
Microsoft Visual Studio, because the installer can download and
70
70
install precompiled library binaries, saving you the trouble of
73
73
binaries when given the option.</p>
74
74
<p>If you're using an earlier version of Visual Studio or some other
75
75
compiler, or if you prefer to build everything yourself, you can
76
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">.7z</tt></a> or <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">.zip</tt></a> and unpack it to install a complete Boost
76
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">.7z</tt></a> or <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">.zip</tt></a> and unpack it to install a complete Boost
77
77
distribution.<a class="footnote-reference" href="#zip" id="id2"><sup>1</sup></a></p>
78
78
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
79
79
<!-- Software License, Version 1.0. (See accompanying -->
80
80
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
82
82
<div class="section" id="the-boost-distribution">
83
<h1><a class="toc-backref" href="#id30">2 The Boost Distribution</a></h1>
83
<h1><a class="toc-backref" href="#id29">2 The Boost Distribution</a></h1>
84
84
<p>This is a sketch of the resulting directory structure:</p>
85
85
<pre class="literal-block">
86
<strong>boost_1_46_0</strong><strong>\</strong> .................<em>The “boost root directory”</em>
86
<strong>boost_1_46_1</strong><strong>\</strong> .................<em>The “boost root directory”</em>
87
87
<strong>index.htm</strong> .........<em>A copy of www.boost.org starts here</em>
88
88
<strong>boost</strong><strong>\</strong> .........................<em>All Boost Header files</em>
89
89
<strong>lib</strong><strong>\</strong> .....................<em>precompiled library binaries</em>
348
348
<div class="section" id="prepare-to-use-a-boost-library-binary">
349
<h1><a class="toc-backref" href="#id36">5 Prepare to Use a Boost Library Binary</a></h1>
349
<h1><a class="toc-backref" href="#id35">5 Prepare to Use a Boost Library Binary</a></h1>
350
350
<p>If you want to use any of the separately-compiled Boost libraries,
351
351
you'll need to acquire library binaries.</p>
352
352
<div class="section" id="install-visual-studio-binaries">
353
<h2><a class="toc-backref" href="#id37">5.1 Install Visual Studio Binaries</a></h2>
353
<h2><a class="toc-backref" href="#id36">5.1 Install Visual Studio Binaries</a></h2>
354
354
<p>The installers supplied by BoostPro Computing will download and
355
355
install pre-compiled binaries into the <tt class="docutils literal">lib\</tt> subdirectory of the
356
boost root, typically <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_0</tt><tt class="docutils literal">\lib\</tt>. If you installed
356
boost root, typically <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_1</tt><tt class="docutils literal">\lib\</tt>. If you installed
357
357
all variants of the <a class="reference external" href="../../libs/regex/index.html">Boost.Regex</a> binary, you're done with this
358
358
step. Otherwise, please run the installer again and install them
360
360
<p><a class="reference internal" href="#link-your-program-to-a-boost-library"><em>skip to the next step</em></a></p>
362
362
<div class="section" id="or-simplified-build-from-source">
363
<h2><a class="toc-backref" href="#id38">5.2 Or, Simplified Build From Source</a></h2>
363
<h2><a class="toc-backref" href="#id37">5.2 Or, Simplified Build From Source</a></h2>
364
364
<p>If you wish to build from source with Visual C++, you can use a
365
365
simple build procedure described in this section. Open the command prompt
366
366
and change your current directory to the Boost root directory. Then, type
387
387
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
388
388
<!-- Software License, Version 1.0. (See accompanying -->
389
389
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
390
<div class="section" id="install-boost-build">
391
<h3><a class="toc-backref" href="#id39">5.3.1 Install Boost.Build</a></h3>
390
392
<p><a class="reference external" href="../../tools/build/index.html">Boost.Build</a> is a text-based system for developing, testing, and
391
installing software. To use it, you'll need an executable called
392
<tt class="docutils literal">bjam</tt>.</p>
393
<!-- .. _Boost.Jam documentation: Boost.Jam_ -->
394
<div class="section" id="get-bjam">
395
<h3><a class="toc-backref" href="#id40">5.3.1 Get <tt class="docutils literal">bjam</tt></a></h3>
396
<p><tt class="docutils literal">bjam</tt> is the <a class="reference internal" href="#command-line-tool">command-line tool</a> that drives the Boost Build
397
system. To build Boost binaries, you'll invoke <tt class="docutils literal">bjam</tt> from the
399
<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.
400
Alternatively, you can build <tt class="docutils literal">bjam</tt> yourself using <a class="reference external" href="../../doc/html/jam/building.html">these
401
instructions</a>.</p>
402
<p>Move the <tt class="docutils literal">bjam</tt> executable into a directory in your PATH. You can
403
see the list of directories in your PATH, separated by semicolons,
404
by typing “<tt class="docutils literal">PATH</tt>” at the command prompt.</p>
393
installing software. First, you'll need to build and
394
install it. To do this:</p>
395
<ol class="arabic simple">
396
<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>
397
<li>Run <tt class="docutils literal">bootstrap.bat</tt></li>
398
<li>Run <tt class="docutils literal">bjam install <span class="pre">--prefix=</span></tt><em>PREFIX</em> where <em>PREFIX</em> is
399
the directory where you want Boost.Build to be installed</li>
400
<li>Add <em>PREFIX</em><tt class="docutils literal">\</tt><tt class="docutils literal">bin</tt> to your PATH environment variable.</li>
406
403
<div class="section" id="identify-your-toolset">
407
<span id="toolset-name"></span><span id="toolset"></span><h3><a class="toc-backref" href="#id41">5.3.2 Identify Your Toolset</a></h3>
404
<span id="toolset-name"></span><span id="toolset"></span><h3><a class="toc-backref" href="#id40">5.3.2 Identify Your Toolset</a></h3>
408
405
<p>First, find the toolset corresponding to your compiler in the
409
406
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
410
407
Boost.Build documentation</a>).</p>
411
408
<div class="note">
412
409
<p class="first admonition-title">Note</p>
413
410
<p class="last">If you previously chose a toolset for the purposes of
414
<a class="reference external" href="../../doc/html/jam/building.html">building bjam</a>, you should assume it won't work and instead
411
<a class="reference external" href="../../doc/html/bbv2/installation.html">building bjam</a>, you should assume it won't work and instead
415
412
choose newly from the table below.</p>
417
414
<table border="1" class="docutils">
514
511
purpose in your current working directory.</p>
516
513
<div class="section" id="invoke-bjam">
517
<h3><a class="toc-backref" href="#id43">5.3.4 Invoke <tt class="docutils literal">bjam</tt></a></h3>
514
<h3><a class="toc-backref" href="#id42">5.3.4 Invoke <tt class="docutils literal">bjam</tt></a></h3>
518
515
<p>Change your current directory to the Boost root directory and
519
516
invoke <tt class="docutils literal">bjam</tt> as follows:</p>
520
517
<pre class="literal-block">
521
bjam <strong>--build-dir=</strong><a class="reference internal" href="#id14"><em>build-directory</em></a> <strong>toolset=</strong><a class="reference internal" href="#toolset-name"><em>toolset-name</em></a> <strong>--build-type=complete</strong> stage
518
bjam <strong>--build-dir=</strong><a class="reference internal" href="#id13"><em>build-directory</em></a> <strong>toolset=</strong><a class="reference internal" href="#toolset-name"><em>toolset-name</em></a> <strong>--build-type=complete</strong> stage
523
520
<p>For a complete description of these and other invocation options,
524
521
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>
525
<p>For example, your session might look like this:<a class="footnote-reference" href="#continuation" id="id16"><sup>4</sup></a></p>
522
<p>For example, your session might look like this:<a class="footnote-reference" href="#continuation" id="id15"><sup>4</sup></a></p>
526
523
<pre class="literal-block">
527
C:\WINDOWS> cd <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_0</tt>
528
<tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_0</tt>> bjam <strong>^</strong>
524
C:\WINDOWS> cd <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_1</tt>
525
<tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_1</tt>> bjam <strong>^</strong>
529
526
More? <strong>--build-dir=</strong>"C:\Documents and Settings\dave\build-boost" <strong>^</strong>
530
527
More? <strong>--build-type=complete</strong> <strong>msvc</strong> stage
664
661
select <em>Properties</em> from the resulting pop-up menu</li>
665
662
<li>In <em>Configuration Properties</em> > <em>Linker</em> > <em>Additional Library
666
663
Directories</em>, enter the path to the Boost binaries,
667
e.g. <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_0</tt><tt class="docutils literal">\lib\</tt>.</li>
664
e.g. <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_1</tt><tt class="docutils literal">\lib\</tt>.</li>
668
665
<li>From the <em>Build</em> menu, select <em>Build Solution</em>.</li>
670
667
<p><a class="reference internal" href="#test-your-program"><em>skip to the next step</em></a></p>
672
669
<div class="section" id="or-link-from-the-command-prompt">
673
<h2><a class="toc-backref" href="#id48">6.2 Or, Link From the Command Prompt</a></h2>
670
<h2><a class="toc-backref" href="#id47">6.2 Or, Link From the Command Prompt</a></h2>
674
671
<p>For example, we can compile and link the above program from the
675
672
Visual C++ command-line by simply adding the <strong>bold</strong> text below to
676
673
the command line we used earlier, assuming your Boost binaries are
677
in <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_0</tt><tt class="docutils literal">\lib</tt>:</p>
674
in <tt class="docutils literal"><span class="pre">C:\Program</span> Files\boost\</tt><tt class="docutils literal">boost_1_46_1</tt><tt class="docutils literal">\lib</tt>:</p>
678
675
<pre class="literal-block">
679
cl /EHsc /I <em>path\to\</em><tt class="docutils literal">boost_1_46_0</tt> example.cpp <strong>^</strong>
680
<strong>/link /LIBPATH:</strong><strong>C:\Program Files\boost\</strong><strong>boost_1_46_0</strong><strong>\lib</strong>
676
cl /EHsc /I <em>path\to\</em><tt class="docutils literal">boost_1_46_1</tt> example.cpp <strong>^</strong>
677
<strong>/link /LIBPATH:</strong><strong>C:\Program Files\boost\</strong><strong>boost_1_46_1</strong><strong>\lib</strong>
683
680
<div class="section" id="library-naming">
684
<h2><a class="toc-backref" href="#id49">6.3 Library Naming</a></h2>
681
<h2><a class="toc-backref" href="#id48">6.3 Library Naming</a></h2>
685
682
<div class="note">
686
683
<p class="first admonition-title">Note</p>
687
684
<p>If, like Visual C++, your compiler supports auto-linking,