<h1class="title"><aclass="reference"href="../../index.htm"><imgalt="Boost"class="boost-logo"src="../../boost.png"/></a> Getting Started on Windows</h1>
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<pclass="first admonition-title">A note to <aclass="reference"href="http://www.cygwin.com">Cygwin</a> and <aclass="reference"href="http://mingw.org">MinGW</a> users</p>
<pclass="last">If you plan to use your tools from the Windows command prompt,
you're in the right place. If you plan to build from the <aclass="reference"href="http://www.cygwin.com">Cygwin</a>
bash shell, you're actually running on a POSIX platform and
should follow the instructions for <aclass="reference"href="unix-variants.html">getting started on Unix
variants</a>. Other command shells, such as <aclass="reference"href="http://mingw.org">MinGW</a>'s MSYS, are
<li><aclass="reference"href="#build-a-simple-program-using-boost"id="id24"name="id24">4 Build a Simple Program Using Boost</a><ulclass="auto-toc">
<li><aclass="reference"href="#build-from-the-visual-studio-ide"id="id25"name="id25">4.1 Build From the Visual Studio IDE</a></li>
<li><aclass="reference"href="#or-build-from-the-command-prompt"id="id26"name="id26">4.2 Or, Build From the Command Prompt</a></li>
<li><aclass="reference"href="#errors-and-warnings"id="id27"name="id27">4.3 Errors and Warnings</a></li>
<li><aclass="reference"href="#prepare-to-use-a-boost-library-binary"id="id28"name="id28">5 Prepare to Use a Boost Library Binary</a><ulclass="auto-toc">
<li><aclass="reference"href="#install-visual-studio-2005-or-net-2003-binaries"id="id29"name="id29">5.1 Install Visual Studio (2005 or .NET 2003) Binaries</a></li>
<li><aclass="reference"href="#or-build-and-install-binaries-from-source"id="id30"name="id30">5.2 Or, Build and Install Binaries From Source</a><ulclass="auto-toc">
<li><aclass="reference"href="#link-your-program-to-a-boost-library"id="id37"name="id37">6 Link Your Program to a Boost Library</a><ulclass="auto-toc">
<li><aclass="reference"href="#link-from-within-the-visual-studio-ide"id="id38"name="id38">6.1 Link From Within the Visual Studio IDE</a></li>
<li><aclass="reference"href="#or-link-from-the-command-prompt"id="id39"name="id39">6.2 Or, Link From the Command Prompt</a></li>
<p>The easiest way to get a copy of Boost is to use the <aclass="reference"href="http://www.boost-consulting.com/download/windows">installer</a>
provided by <aclass="reference"href="http://www.boost-consulting.com">Boost Consulting</a>. We especially recommend this
method if you use Microsoft Visual Studio .NET 2003 or Microsoft
Visual Studio 2005, because the installer can download and install
precompiled library binaries, saving you the trouble of building
them yourself. To complete this tutorial, you'll need to at least
install the <aclass="reference"href="../../libs/regex/index.html">Boost.Regex</a> binaries when given the option.</p>
<p>If you're using an earlier version of Visual Studio or some other
compiler, or if you prefer to build everything yourself, you can
download <aclass="reference"href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=376197"><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt><ttclass="docutils literal"><spanclass="pre">.exe</span></tt></a> and run it to install a complete Boost
<pclass="pre-wrap">The organization of Boost library headers isn't entirely uniform,
but most libraries follow a few patterns:</p>
<ulclass="pre-wrap last">
<li><pclass="first">Some older libraries and most very small libraries place all
public headers directly into <ttclass="docutils literal"><spanclass="pre">boost</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt>.</p>
</li>
<li><pclass="first">Most libraries' public headers live in a subdirectory of
<ttclass="docutils literal"><spanclass="pre">boost</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt>, named after the library. For example, you'll find
the Python library's <ttclass="docutils literal"><spanclass="pre">def.hpp</span></tt> header in</p>
<li><pclass="first">Some libraries have an “aggregate header” in <ttclass="docutils literal"><spanclass="pre">boost</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt> that
<ttclass="docutils literal"><spanclass="pre">#include</span></tt>s all of the library's other headers. For
example, <aclass="reference"href="../../libs/python/doc/building.html">Boost.Python</a>'s aggregate header is</p>
<li><pclass="first">Most libraries place private headers in a subdirectory called
<ttclass="docutils literal"><spanclass="pre">detail</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt>, or <ttclass="docutils literal"><spanclass="pre">aux_</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt>. Don't expect to find
anything you can use in these directories.</p>
</li>
</ul>
</div>
<p>It's important to note the following:</p>
<olclass="arabic"id="boost-root-directory">
<li><pclass="first">The path to the <strong>boost root directory</strong> (often <ttclass="docutils literal"><spanclass="pre">C:\Program</span><spanclass="pre">Files\boost\</span></tt><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt>) is
sometimes referred to as <ttclass="docutils literal"><spanclass="pre">$BOOST_ROOT</span></tt> in documentation and
mailing lists .</p>
</li>
<li><pclass="first">To compile anything in Boost, you need a directory containing
the <ttclass="docutils literal"><spanclass="pre">boost</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt> subdirectory in your <ttclass="docutils literal"><spanclass="pre">#include</span></tt> path. Specific steps for setting up <ttclass="docutils literal"><spanclass="pre">#include</span></tt>
paths in Microsoft Visual Studio follow later in this document;
if you use another IDE, please consult your product's
documentation for instructions.</p>
</li>
<li><pclass="first">Since all of Boost's header files have the <ttclass="docutils literal"><spanclass="pre">.hpp</span></tt> extension,
and live in the <ttclass="docutils literal"><spanclass="pre">boost</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt> subdirectory of the boost root, your
Boost <ttclass="docutils literal"><spanclass="pre">#include</span></tt> directives will look like:</p>
portability reasons, probably should) use forward slashes in
<ttclass="docutils literal"><spanclass="pre">#include</span></tt> directives; your compiler doesn't care.</p>
</li>
<li><pclass="first">Don't be distracted by the <ttclass="docutils literal"><spanclass="pre">doc</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt> subdirectory; it only
contains a subset of the Boost documentation. Start with
<ttclass="docutils literal"><spanclass="pre">libs</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt><ttclass="docutils literal"><spanclass="pre">index.html</span></tt> if you're looking for the whole enchilada.</p>
</li>
</ol>
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<p>A few libraries have optional separately-compiled binaries:</p>
<ulclass="simple">
<li><aclass="reference"href="../../libs/date_time/index.html">Boost.DateTime</a> has a binary component that is only needed if
you're using its <ttclass="docutils literal"><spanclass="pre">to_string</span></tt>/<ttclass="docutils literal"><spanclass="pre">from_string</span></tt> or serialization
features, or if you're targeting Visual C++ 6.x or Borland.</li>
<li><aclass="reference"href="../../libs/graph/index.html">Boost.Graph</a> also has a binary component that is only needed if
you intend to <aclass="reference"href="../../libs/graph/doc/read_graphviz.html">parse GraphViz files</a>.</li>
<li><aclass="reference"href="../../libs/test/index.html">Boost.Test</a> can be used in “header-only” or “separately compiled”
mode, although <strong>separate compilation is recommended for serious
use</strong>.</li>
</ul>
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<h1><aclass="toc-backref"href="#id24"id="build-a-simple-program-using-boost"name="build-a-simple-program-using-boost">4 Build a Simple Program Using Boost</a></h1>
<p>In Windows, a command-line tool is invoked by typing its name,
optionally followed by arguments, into a <em>Command Prompt</em> window
and pressing the Return (or Enter) key.</p>
<p>To open a generic <em>Command Prompt</em>, click the <em>Start</em> menu
button, click <em>Run</em>, type “cmd”, and then click <em>OK</em>.</p>
<pid="current-directory">All commands are executed within the context of a <strong>current
directory</strong> in the filesystem. To set the current directory,
type:</p>
<preclass="literal-block">
cd <em>path</em>\<em>to</em>\<em>some</em>\<em>directory</em>
</pre>
<p>followed by Return. For example,</p>
<preclass="literal-block">
cd <ttclass="docutils literal"><spanclass="pre">C:\Program</span><spanclass="pre">Files\boost\</span></tt><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt>
</pre>
<pclass="last">Long commands can be continued across several lines by typing a
caret (<ttclass="docutils literal"><spanclass="pre">^</span></tt>) at the end of all but the last line. Some examples
on this page use that technique to save horizontal space.</p>
<h2><aclass="toc-backref"href="#id25"id="build-from-the-visual-studio-ide"name="build-from-the-visual-studio-ide"><spanid="vs-header-only"></span>4.1 Build From the Visual Studio IDE</a></h2>
<h2><aclass="toc-backref"href="#id26"id="or-build-from-the-command-prompt"name="or-build-from-the-command-prompt">4.2 Or, Build From the Command Prompt</a></h2>
<h1><aclass="toc-backref"href="#id28"id="prepare-to-use-a-boost-library-binary"name="prepare-to-use-a-boost-library-binary">5 Prepare to Use a Boost Library Binary</a></h1>
<h2><aclass="toc-backref"href="#id29"id="install-visual-studio-2005-or-net-2003-binaries"name="install-visual-studio-2005-or-net-2003-binaries">5.1 Install Visual Studio (2005 or .NET 2003) Binaries</a></h2>
<p>The <aclass="reference"href="http://www.boost-consulting.com/download/windows">installer</a> supplied by Boost Consulting will download and
install pre-compiled binaries into the <ttclass="docutils literal"><spanclass="pre">lib\</span></tt> subdirectory of the
boost root, typically <ttclass="docutils literal"><spanclass="pre">C:\Program</span><spanclass="pre">Files\boost\</span></tt><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt><ttclass="docutils literal"><spanclass="pre">\lib\</span></tt>. If you installed
all variants of the <aclass="reference"href="../../libs/regex/index.html">Boost.Regex</a> binary, you're done with this
step. Otherwise, please run the installer again and install them
now.</p>
<p><aclass="reference"href="#link-your-program-to-a-boost-library"><em>skip to the next step</em></a></p>
<h2><aclass="toc-backref"href="#id30"id="or-build-and-install-binaries-from-source"name="or-build-and-install-binaries-from-source">5.2 Or, Build and Install Binaries From Source</a></h2>
<p><ttclass="docutils literal"><spanclass="pre">bjam</span></tt> is the <aclass="reference"href="#command-line-tool">command-line tool</a> that drives the Boost Build
system. To build Boost binaries, you'll invoke <ttclass="docutils literal"><spanclass="pre">bjam</span></tt> from the
Boost root.</p>
<p>Boost provides <aclass="reference"href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941">pre-compiled <ttclass="docutils literal"><spanclass="pre">bjam</span></tt> executables</a> for a variety of platforms.
Alternatively, you can build <ttclass="docutils literal"><spanclass="pre">bjam</span></tt> yourself using <aclass="reference"href="../../doc/html/jam/building.html">these
<h3><aclass="toc-backref"href="#id32"id="identify-your-toolset"name="identify-your-toolset"><spanid="toolset-name"></span><spanid="toolset"></span>5.2.2 Identify Your Toolset</a></h3>
<p>If you have multiple versions of a particular compiler installed,
you can append the version number to the toolset name, preceded by a
hyphen, e.g. <ttclass="docutils literal"><spanclass="pre">msvc-7.1</span></tt> or <ttclass="docutils literal"><spanclass="pre">gcc-3.4</span></tt>.</p>
<divclass="note">
<pclass="first admonition-title">Note</p>
<pclass="last">if you built <ttclass="docutils literal"><spanclass="pre">bjam</span></tt> yourself, you may
have selected a toolset name for that purpose, but that does not
affect this step in any way; you still need to select a Boost.Build
<h3><aclass="toc-backref"href="#id33"id="select-a-build-directory"name="select-a-build-directory"><spanid="id11"></span><spanid="build-directory"></span>5.2.3 Select a Build Directory</a></h3>
<p>For example, your session might look like this:<aclass="footnote-reference"href="#continuation"id="id12"name="id12"><sup>4</sup></a></p>
<preclass="literal-block">
C:WINDOWS> cd <ttclass="docutils literal"><spanclass="pre">C:\Program</span><spanclass="pre">Files\boost\</span></tt><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt>
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<p>Boost.Build will place the Boost binaries in the <ttclass="docutils literal"><spanclass="pre">stage</span></tt><ttclass="docutils literal"><spanclass="pre">\</span></tt>
subdirectory of your <aclass="reference"href="#build-directory">build directory</a>.</p>
<divclass="note">
<pclass="first admonition-title">Note</p>
<pclass="last"><ttclass="docutils literal"><spanclass="pre">bjam</span></tt> is case-sensitive; it is important that all the
parts shown in <strong>bold</strong> type above be entirely lower-case.</p>
</div>
<p>For a description of other options you can pass when invoking
<p>In particular, to limit the amount of time spent building, you may
be interested in:</p>
<ulclass="simple">
<li>reviewing the list of library names with <ttclass="docutils literal"><spanclass="pre">--show-libraries</span></tt></li>
<li>limiting which libraries get built with the <ttclass="docutils literal"><spanclass="pre">--with-</span></tt><em>library-name</em> or <ttclass="docutils literal"><spanclass="pre">--without-</span></tt><em>library-name</em> options</li>
<li>choosing a specific build variant by adding <ttclass="docutils literal"><spanclass="pre">release</span></tt> or
<ttclass="docutils literal"><spanclass="pre">debug</span></tt> to the command line.</li>
<h1><aclass="toc-backref"href="#id37"id="link-your-program-to-a-boost-library"name="link-your-program-to-a-boost-library">6 Link Your Program to a Boost Library</a></h1>
<h2><aclass="toc-backref"href="#id38"id="link-from-within-the-visual-studio-ide"name="link-from-within-the-visual-studio-ide">6.1 Link From Within the Visual Studio IDE</a></h2>
Directories</em>, enter the path to the Boost binaries,
e.g. <ttclass="docutils literal"><spanclass="pre">C:\Program</span><spanclass="pre">Files\boost\</span></tt><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt><ttclass="docutils literal"><spanclass="pre">\lib\</span></tt>.</li>
<li>From the <em>Build</em> menu, select <em>Build Solution</em>.</li>
</ol>
<p><aclass="reference"href="#test-your-program"><em>skip to the next step</em></a></p>
<h2><aclass="toc-backref"href="#id39"id="or-link-from-the-command-prompt"name="or-link-from-the-command-prompt">6.2 Or, Link From the Command Prompt</a></h2>
<p>For example, we can compile and link the above program from the
Visual C++ command-line by simply adding the <strong>bold</strong> text below to
the command line we used earlier, assuming your Boost binaries are
in <ttclass="docutils literal"><spanclass="pre">C:\Program</span><spanclass="pre">Files\boost\</span></tt><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt><ttclass="docutils literal"><spanclass="pre">\lib</span></tt>:</p>
convention. On most unix-style platforms the extensions are
<ttclass="docutils literal"><spanclass="pre">.a</span></tt> and <ttclass="docutils literal"><spanclass="pre">.so</span></tt> for static libraries (archives) and shared
libraries, respectively. On Windows, <ttclass="docutils literal"><spanclass="pre">.dll</span></tt> indicates a shared
library and (except for static libraries built by the <ttclass="docutils literal"><spanclass="pre">gcc</span></tt>
toolset, whose names always end in <ttclass="docutils literal"><spanclass="pre">.a</span></tt>) <ttclass="docutils literal"><spanclass="pre">.lib</span></tt> indicates a
static or import library. Where supported by toolsets on unix
variants, a full version extension is added (e.g. ".so.1.34") and
a symbolic link to the library file, named without the trailing
<h1><aclass="toc-backref"href="#id42"id="conclusion-and-further-resources"name="conclusion-and-further-resources">7 Conclusion and Further Resources</a></h1>
<tr><tdclass="label"><aclass="fn-backref"href="#id2"name="zip">[1]</a></td><td>If you prefer not to download executable programs,
download <aclass="reference"href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=376197"><ttclass="docutils literal"><spanclass="pre">boost_1_34_0</span></tt><ttclass="docutils literal"><spanclass="pre">.zip</span></tt></a> and use an external tool to decompress
it. We don't recommend using Windows' built-in decompression as
it can be painfully slow for large archives.</td></tr>
<tr><tdclass="label"><aname="installer-src">[2]</a></td><td>If you used the <aclass="reference"href="http://www.boost-consulting.com/download/windows">installer</a> from Boost
Consulting and deselected “Source and Documentation” (it's
selected by default), you won't see the <ttclass="docutils literal"><spanclass="pre">libs/</span></tt> subdirectory.
That won't affect your ability to use precompiled binaries, but
you won't be able to rebuild libraries from scratch.</td></tr>
<tr><tdclass="label"><aclass="fn-backref"href="#id12"name="continuation">[4]</a></td><td>In this example, the caret character <ttclass="docutils literal"><spanclass="pre">^</span></tt> is a
way of continuing the command on multiple lines. The command
prompt responds with <ttclass="docutils literal"><spanclass="pre">More?</span></tt> to prompt for more input. Feel
free to omit the carets and subsequent newlines; we used them so
the example would fit on a page of reasonable width.</td></tr>
</tbody>
</table>
<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<ttclass="docutils literal"><spanclass="pre">NDEBUG</span></tt><ttclass="docutils literal"><spanclass="pre">#define</span></tt>d. Although it's true that sometimes