windows.html 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
  7. <title>Boost Getting Started on Windows</title>
  8. <link rel="stylesheet" href="../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-getting-started-on-windows">
  12. <h1 class="title"><a class="reference" href="../../index.htm"><img alt="Boost" class="boost-logo" src="../../boost.png" /></a> Getting Started on Windows</h1>
  13. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  14. <!-- Software License, Version 1.0. (See accompanying -->
  15. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  16. <div class="admonition-a-note-to-cygwin-and-mingw-users admonition">
  17. <p class="first admonition-title">A note to <a class="reference" href="http://www.cygwin.com">Cygwin</a> and <a class="reference" href="http://mingw.org">MinGW</a> users</p>
  18. <p class="last">If you plan to use your tools from the Windows command prompt,
  19. you're in the right place. If you plan to build from the <a class="reference" href="http://www.cygwin.com">Cygwin</a>
  20. bash shell, you're actually running on a POSIX platform and
  21. should follow the instructions for <a class="reference" href="unix-variants.html">getting started on Unix
  22. variants</a>. Other command shells, such as <a class="reference" href="http://mingw.org">MinGW</a>'s MSYS, are
  23. not supported—they may or may not work.</p>
  24. </div>
  25. <div class="contents topic">
  26. <p class="topic-title first"><a id="index" name="index">Index</a></p>
  27. <ul class="auto-toc simple">
  28. <li><a class="reference" href="#get-boost" id="id21" name="id21">1&nbsp;&nbsp;&nbsp;Get Boost</a></li>
  29. <li><a class="reference" href="#the-boost-distribution" id="id22" name="id22">2&nbsp;&nbsp;&nbsp;The Boost Distribution</a></li>
  30. <li><a class="reference" href="#header-only-libraries" id="id23" name="id23">3&nbsp;&nbsp;&nbsp;Header-Only Libraries</a></li>
  31. <li><a class="reference" href="#build-a-simple-program-using-boost" id="id24" name="id24">4&nbsp;&nbsp;&nbsp;Build a Simple Program Using Boost</a><ul class="auto-toc">
  32. <li><a class="reference" href="#build-from-the-visual-studio-ide" id="id25" name="id25">4.1&nbsp;&nbsp;&nbsp;Build From the Visual Studio IDE</a></li>
  33. <li><a class="reference" href="#or-build-from-the-command-prompt" id="id26" name="id26">4.2&nbsp;&nbsp;&nbsp;Or, Build From the Command Prompt</a></li>
  34. <li><a class="reference" href="#errors-and-warnings" id="id27" name="id27">4.3&nbsp;&nbsp;&nbsp;Errors and Warnings</a></li>
  35. </ul>
  36. </li>
  37. <li><a class="reference" href="#prepare-to-use-a-boost-library-binary" id="id28" name="id28">5&nbsp;&nbsp;&nbsp;Prepare to Use a Boost Library Binary</a><ul class="auto-toc">
  38. <li><a class="reference" href="#install-visual-studio-2005-or-net-2003-binaries" id="id29" name="id29">5.1&nbsp;&nbsp;&nbsp;Install Visual Studio (2005 or .NET 2003) Binaries</a></li>
  39. <li><a class="reference" href="#or-build-and-install-binaries-from-source" id="id30" name="id30">5.2&nbsp;&nbsp;&nbsp;Or, Build and Install Binaries From Source</a><ul class="auto-toc">
  40. <li><a class="reference" href="#get-bjam" id="id31" name="id31">5.2.1&nbsp;&nbsp;&nbsp;Get <tt class="docutils literal"><span class="pre">bjam</span></tt></a></li>
  41. <li><a class="reference" href="#identify-your-toolset" id="id32" name="id32">5.2.2&nbsp;&nbsp;&nbsp;Identify Your Toolset</a></li>
  42. <li><a class="reference" href="#select-a-build-directory" id="id33" name="id33">5.2.3&nbsp;&nbsp;&nbsp;Select a Build Directory</a></li>
  43. <li><a class="reference" href="#invoke-bjam" id="id34" name="id34">5.2.4&nbsp;&nbsp;&nbsp;Invoke <tt class="docutils literal"><span class="pre">bjam</span></tt></a></li>
  44. </ul>
  45. </li>
  46. <li><a class="reference" href="#expected-build-output" id="id35" name="id35">5.3&nbsp;&nbsp;&nbsp;Expected Build Output</a></li>
  47. <li><a class="reference" href="#in-case-of-build-errors" id="id36" name="id36">5.4&nbsp;&nbsp;&nbsp;In Case of Build Errors</a></li>
  48. </ul>
  49. </li>
  50. <li><a class="reference" href="#link-your-program-to-a-boost-library" id="id37" name="id37">6&nbsp;&nbsp;&nbsp;Link Your Program to a Boost Library</a><ul class="auto-toc">
  51. <li><a class="reference" href="#link-from-within-the-visual-studio-ide" id="id38" name="id38">6.1&nbsp;&nbsp;&nbsp;Link From Within the Visual Studio IDE</a></li>
  52. <li><a class="reference" href="#or-link-from-the-command-prompt" id="id39" name="id39">6.2&nbsp;&nbsp;&nbsp;Or, Link From the Command Prompt</a></li>
  53. <li><a class="reference" href="#library-naming" id="id40" name="id40">6.3&nbsp;&nbsp;&nbsp;Library Naming</a></li>
  54. <li><a class="reference" href="#test-your-program" id="id41" name="id41">6.4&nbsp;&nbsp;&nbsp;Test Your Program</a></li>
  55. </ul>
  56. </li>
  57. <li><a class="reference" href="#conclusion-and-further-resources" id="id42" name="id42">7&nbsp;&nbsp;&nbsp;Conclusion and Further Resources</a></li>
  58. </ul>
  59. </div>
  60. <div class="section">
  61. <h1><a class="toc-backref" href="#id21" id="get-boost" name="get-boost">1&nbsp;&nbsp;&nbsp;Get Boost</a></h1>
  62. <p>The easiest way to get a copy of Boost is to use the <a class="reference" href="http://www.boost-consulting.com/download/windows">installer</a>
  63. provided by <a class="reference" href="http://www.boost-consulting.com">Boost Consulting</a>. We especially recommend this
  64. method if you use Microsoft Visual Studio .NET 2003 or Microsoft
  65. Visual Studio 2005, because the installer can download and install
  66. precompiled library binaries, saving you the trouble of building
  67. them yourself. To complete this tutorial, you'll need to at least
  68. install the <a class="reference" href="../../libs/regex/index.html">Boost.Regex</a> binaries when given the option.</p>
  69. <p>If you're using an earlier version of Visual Studio or some other
  70. compiler, or if you prefer to build everything yourself, you can
  71. download <a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=7586&amp;package_id=8041&amp;release_id=376197"><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt><tt class="docutils literal"><span class="pre">.exe</span></tt></a> and run it to install a complete Boost
  72. distribution.<a class="footnote-reference" href="#zip" id="id2" name="id2"><sup>1</sup></a></p>
  73. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  74. <!-- Software License, Version 1.0. (See accompanying -->
  75. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  76. </div>
  77. <div class="section">
  78. <h1><a class="toc-backref" href="#id22" id="the-boost-distribution" name="the-boost-distribution">2&nbsp;&nbsp;&nbsp;The Boost Distribution</a></h1>
  79. <p>This is a sketch of the resulting directory structure:</p>
  80. <pre class="literal-block">
  81. <strong>boost_1_34_0</strong><strong>\</strong> .................<em>The “boost root directory”</em>
  82. <strong>index.htm</strong> .........<em>A copy of www.boost.org starts here</em>
  83. <strong>boost</strong><strong>\</strong> .........................<em>All Boost Header files</em>
  84. <strong>lib</strong><strong>\</strong> .....................<em>precompiled library binaries</em>
  85. <strong>libs</strong><strong>\</strong> ............<em>Tests, .cpp</em>s<em>, docs, etc., by library</em>
  86. <strong>index.html</strong> ........<em>Library documentation starts here</em>
  87. <strong>algorithm</strong><strong>\</strong>
  88. <strong>any</strong><strong>\</strong>
  89. <strong>array</strong><strong>\</strong>
  90. <em>…more libraries…</em>
  91. <strong>status</strong><strong>\</strong> .........................<em>Boost-wide test suite</em>
  92. <strong>tools</strong><strong>\</strong> ...........<em>Utilities, e.g. bjam, quickbook, bcp</em>
  93. <strong>more</strong><strong>\</strong> ..........................<em>Policy documents, etc.</em>
  94. <strong>doc</strong><strong>\</strong> ...............<em>A subset of all Boost library docs</em>
  95. </pre>
  96. <div class="sidebar">
  97. <p class="first sidebar-title">Header Organization</p>
  98. <p class="pre-wrap">The organization of Boost library headers isn't entirely uniform,
  99. but most libraries follow a few patterns:</p>
  100. <ul class="pre-wrap last">
  101. <li><p class="first">Some older libraries and most very small libraries place all
  102. public headers directly into <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt>.</p>
  103. </li>
  104. <li><p class="first">Most libraries' public headers live in a subdirectory of
  105. <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt>, named after the library. For example, you'll find
  106. the Python library's <tt class="docutils literal"><span class="pre">def.hpp</span></tt> header in</p>
  107. <pre class="literal-block">
  108. <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt><tt class="docutils literal"><span class="pre">python</span></tt><tt class="docutils literal"><span class="pre">\</span></tt><tt class="docutils literal"><span class="pre">def.hpp</span></tt>.
  109. </pre>
  110. </li>
  111. <li><p class="first">Some libraries have an “aggregate header” in <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt> that
  112. <tt class="docutils literal"><span class="pre">#include</span></tt>s all of the library's other headers. For
  113. example, <a class="reference" href="../../libs/python/doc/building.html">Boost.Python</a>'s aggregate header is</p>
  114. <pre class="literal-block">
  115. <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt><tt class="docutils literal"><span class="pre">python.hpp</span></tt>.
  116. </pre>
  117. </li>
  118. <li><p class="first">Most libraries place private headers in a subdirectory called
  119. <tt class="docutils literal"><span class="pre">detail</span></tt><tt class="docutils literal"><span class="pre">\</span></tt>, or <tt class="docutils literal"><span class="pre">aux_</span></tt><tt class="docutils literal"><span class="pre">\</span></tt>. Don't expect to find
  120. anything you can use in these directories.</p>
  121. </li>
  122. </ul>
  123. </div>
  124. <p>It's important to note the following:</p>
  125. <ol class="arabic" id="boost-root-directory">
  126. <li><p class="first">The path to the <strong>boost root directory</strong> (often <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt>) is
  127. sometimes referred to as <tt class="docutils literal"><span class="pre">$BOOST_ROOT</span></tt> in documentation and
  128. mailing lists .</p>
  129. </li>
  130. <li><p class="first">To compile anything in Boost, you need a directory containing
  131. the <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt> subdirectory in your <tt class="docutils literal"><span class="pre">#include</span></tt> path. Specific steps for setting up <tt class="docutils literal"><span class="pre">#include</span></tt>
  132. paths in Microsoft Visual Studio follow later in this document;
  133. if you use another IDE, please consult your product's
  134. documentation for instructions.</p>
  135. </li>
  136. <li><p class="first">Since all of Boost's header files have the <tt class="docutils literal"><span class="pre">.hpp</span></tt> extension,
  137. and live in the <tt class="docutils literal"><span class="pre">boost</span></tt><tt class="docutils literal"><span class="pre">\</span></tt> subdirectory of the boost root, your
  138. Boost <tt class="docutils literal"><span class="pre">#include</span></tt> directives will look like:</p>
  139. <pre class="literal-block">
  140. #include &lt;boost/<em>whatever</em>.hpp&gt;
  141. </pre>
  142. <p>or</p>
  143. <pre class="literal-block">
  144. #include &quot;boost/<em>whatever</em>.hpp&quot;
  145. </pre>
  146. <p>depending on your preference regarding the use of angle bracket
  147. includes. Even Windows users can (and, for
  148. portability reasons, probably should) use forward slashes in
  149. <tt class="docutils literal"><span class="pre">#include</span></tt> directives; your compiler doesn't care.</p>
  150. </li>
  151. <li><p class="first">Don't be distracted by the <tt class="docutils literal"><span class="pre">doc</span></tt><tt class="docutils literal"><span class="pre">\</span></tt> subdirectory; it only
  152. contains a subset of the Boost documentation. Start with
  153. <tt class="docutils literal"><span class="pre">libs</span></tt><tt class="docutils literal"><span class="pre">\</span></tt><tt class="docutils literal"><span class="pre">index.html</span></tt> if you're looking for the whole enchilada.</p>
  154. </li>
  155. </ol>
  156. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  157. <!-- Software License, Version 1.0. (See accompanying -->
  158. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  159. </div>
  160. <div class="section">
  161. <h1><a class="toc-backref" href="#id23" id="header-only-libraries" name="header-only-libraries">3&nbsp;&nbsp;&nbsp;Header-Only Libraries</a></h1>
  162. <p>The first thing many people want to know is, “how do I build
  163. Boost?” The good news is that often, there's nothing to build.</p>
  164. <div class="admonition-nothing-to-build admonition">
  165. <p class="first admonition-title">Nothing to Build?</p>
  166. <p class="last">Most Boost libraries are <strong>header-only</strong>: they consist <em>entirely
  167. of header files</em> containing templates and inline functions, and
  168. require no separately-compiled library binaries or special
  169. treatment when linking.</p>
  170. </div>
  171. <p id="separate">The only Boost libraries that <em>must</em> be built separately are:</p>
  172. <ul class="simple">
  173. <li><a class="reference" href="../../libs/filesystem/index.html">Boost.Filesystem</a></li>
  174. <li><a class="reference" href="../../libs/iostreams/index.html">Boost.IOStreams</a></li>
  175. <li><a class="reference" href="../../libs/program_options/index.html">Boost.ProgramOptions</a></li>
  176. <li><a class="reference" href="../../libs/python/doc/building.html">Boost.Python</a></li>
  177. <li><a class="reference" href="../../libs/regex/index.html">Boost.Regex</a></li>
  178. <li><a class="reference" href="../../libs/serialization/index.html">Boost.Serialization</a></li>
  179. <li><a class="reference" href="../../libs/signals/index.html">Boost.Signals</a></li>
  180. <li><a class="reference" href="../../libs/thread/index.html">Boost.Thread</a></li>
  181. <li><a class="reference" href="../../libs/wave/index.html">Boost.Wave</a></li>
  182. </ul>
  183. <p>A few libraries have optional separately-compiled binaries:</p>
  184. <ul class="simple">
  185. <li><a class="reference" href="../../libs/date_time/index.html">Boost.DateTime</a> has a binary component that is only needed if
  186. you're using its <tt class="docutils literal"><span class="pre">to_string</span></tt>/<tt class="docutils literal"><span class="pre">from_string</span></tt> or serialization
  187. features, or if you're targeting Visual C++ 6.x or Borland.</li>
  188. <li><a class="reference" href="../../libs/graph/index.html">Boost.Graph</a> also has a binary component that is only needed if
  189. you intend to <a class="reference" href="../../libs/graph/doc/read_graphviz.html">parse GraphViz files</a>.</li>
  190. <li><a class="reference" href="../../libs/test/index.html">Boost.Test</a> can be used in “header-only” or “separately compiled”
  191. mode, although <strong>separate compilation is recommended for serious
  192. use</strong>.</li>
  193. </ul>
  194. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  195. <!-- Software License, Version 1.0. (See accompanying -->
  196. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  197. </div>
  198. <div class="section">
  199. <h1><a class="toc-backref" href="#id24" id="build-a-simple-program-using-boost" name="build-a-simple-program-using-boost">4&nbsp;&nbsp;&nbsp;Build a Simple Program Using Boost</a></h1>
  200. <p>To keep things simple, let's start by using a header-only library.
  201. The following program reads a sequence of integers from standard
  202. input, uses Boost.Lambda to multiply each number by three, and
  203. writes them to standard output:</p>
  204. <pre class="literal-block">
  205. #include &lt;boost/lambda/lambda.hpp&gt;
  206. #include &lt;iostream&gt;
  207. #include &lt;iterator&gt;
  208. #include &lt;algorithm&gt;
  209. int main()
  210. {
  211. using namespace boost::lambda;
  212. typedef std::istream_iterator&lt;int&gt; in;
  213. std::for_each(
  214. in(std::cin), in(), std::cout &lt;&lt; (_1 * 3) &lt;&lt; &quot; &quot; );
  215. }
  216. </pre>
  217. <p>Copy the text of this program into a file called <tt class="docutils literal"><span class="pre">example.cpp</span></tt>.</p>
  218. <div class="note">
  219. <p class="first admonition-title"><a id="command-line-tool" name="command-line-tool"><span id="command-prompt"></span>Note</a></p>
  220. <p class="last">To build the examples in this guide, you can use an
  221. Integrated Development Environment (IDE) like Visual Studio, or
  222. you can issue commands from the <a class="reference" href="#command-prompt">command prompt</a>. Since every
  223. IDE and compiler has different options and Microsoft's are by
  224. far the dominant compilers on Windows, we only give specific
  225. directions here for Visual Studio 2005 and .NET 2003 IDEs and
  226. their respective command prompt compilers (using the command
  227. prompt is a bit simpler). If you are using another compiler or
  228. IDE, it should be relatively easy to adapt these instructions to
  229. your environment.</p>
  230. </div>
  231. <div class="small sidebar">
  232. <p class="first sidebar-title">Command Prompt Basics</p>
  233. <p>In Windows, a command-line tool is invoked by typing its name,
  234. optionally followed by arguments, into a <em>Command Prompt</em> window
  235. and pressing the Return (or Enter) key.</p>
  236. <p>To open a generic <em>Command Prompt</em>, click the <em>Start</em> menu
  237. button, click <em>Run</em>, type “cmd”, and then click <em>OK</em>.</p>
  238. <p id="current-directory">All commands are executed within the context of a <strong>current
  239. directory</strong> in the filesystem. To set the current directory,
  240. type:</p>
  241. <pre class="literal-block">
  242. cd <em>path</em>\<em>to</em>\<em>some</em>\<em>directory</em>
  243. </pre>
  244. <p>followed by Return. For example,</p>
  245. <pre class="literal-block">
  246. cd <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt>
  247. </pre>
  248. <p class="last">Long commands can be continued across several lines by typing a
  249. caret (<tt class="docutils literal"><span class="pre">^</span></tt>) at the end of all but the last line. Some examples
  250. on this page use that technique to save horizontal space.</p>
  251. </div>
  252. <div class="section">
  253. <h2><a class="toc-backref" href="#id25" id="build-from-the-visual-studio-ide" name="build-from-the-visual-studio-ide"><span id="vs-header-only"></span>4.1&nbsp;&nbsp;&nbsp;Build From the Visual Studio IDE</a></h2>
  254. <ul>
  255. <li><p class="first">From Visual Studio's <em>File</em> menu, select <em>New</em> &gt; <em>Project…</em></p>
  256. </li>
  257. <li><p class="first">In the left-hand pane of the resulting <em>New Project</em> dialog,
  258. select <em>Visual C++</em> &gt; <em>Win32</em>.</p>
  259. </li>
  260. <li><p class="first">In the right-hand pane, select <em>Win32 Console Application</em>
  261. (VS8.0) or <em>Win32 Console Project</em> (VS7.1).</p>
  262. </li>
  263. <li><p class="first">In the <em>name</em> field, enter “example”</p>
  264. </li>
  265. <li><p class="first">Right-click <strong>example</strong> in the <em>Solution Explorer</em> pane and
  266. select <em>Properties</em> from the resulting pop-up menu</p>
  267. </li>
  268. <li><p class="first">In <em>Configuration Properties</em> &gt; <em>C/C++</em> &gt; <em>General</em> &gt; <em>Additional Include
  269. Directories</em>, enter the path to the Boost root directory, for example</p>
  270. <blockquote>
  271. <p><tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt></p>
  272. </blockquote>
  273. </li>
  274. <li><p class="first">In <em>Configuration Properties</em> &gt; <em>C/C++</em> &gt; <em>Precompiled Headers</em>, change
  275. <em>Use Precompiled Header (/Yu)</em> to <em>Not Using Precompiled
  276. Headers</em>.<a class="footnote-reference" href="#pch" id="id4" name="id4"><sup>3</sup></a></p>
  277. </li>
  278. <li><p class="first">Replace the contents of the <tt class="docutils literal"><span class="pre">example.cpp</span></tt> generated by the IDE
  279. with the example code above.</p>
  280. </li>
  281. <li><p class="first">From the <em>Build</em> menu, select <em>Build Solution</em>.</p>
  282. </li>
  283. </ul>
  284. <p>To test your application, hit the F5 key and type the following
  285. into the resulting window, followed by the Return key:</p>
  286. <pre class="literal-block">
  287. 1 2 3
  288. </pre>
  289. <p>Then hold down the control key and press &quot;Z&quot;, followed by the
  290. Return key.</p>
  291. <p><a class="reference" href="#errors-and-warnings"><em>skip to the next step</em></a></p>
  292. </div>
  293. <div class="section">
  294. <h2><a class="toc-backref" href="#id26" id="or-build-from-the-command-prompt" name="or-build-from-the-command-prompt">4.2&nbsp;&nbsp;&nbsp;Or, Build From the Command Prompt</a></h2>
  295. <p>From your computer's <em>Start</em> menu, if you are a Visual
  296. Studio 2005 user, select</p>
  297. <blockquote>
  298. <em>All Programs</em> &gt; <em>Microsoft Visual Studio 2005</em>
  299. &gt; <em>Visual Studio Tools</em> &gt; <em>Visual Studio 2005 Command Prompt</em></blockquote>
  300. <p>or, if you're a Visual Studio .NET 2003 user, select</p>
  301. <blockquote>
  302. <em>All Programs</em> &gt; <em>Microsoft Visual Studio .NET 2003</em>
  303. &gt; <em>Visual Studio .NET Tools</em> &gt; <em>Visual Studio .NET 2003 Command Prompt</em></blockquote>
  304. <p>to bring up a special <a class="reference" href="#command-prompt">command prompt</a> window set up for the
  305. Visual Studio compiler. In that window, set the <a class="reference" href="#current-directory">current
  306. directory</a> to a suitable location for creating some temporary
  307. files and type the following command followed by the Return key:</p>
  308. <pre class="literal-block">
  309. cl /EHsc /I <em>path\to\</em><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt> <em>path</em>\<em>to</em>\example.cpp
  310. </pre>
  311. <p>To test the result, type:</p>
  312. <pre class="literal-block">
  313. echo 1 2 3 | example
  314. </pre>
  315. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  316. <!-- Software License, Version 1.0. (See accompanying -->
  317. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  318. </div>
  319. <div class="section">
  320. <h2><a class="toc-backref" href="#id27" id="errors-and-warnings" name="errors-and-warnings">4.3&nbsp;&nbsp;&nbsp;Errors and Warnings</a></h2>
  321. <p>Don't be alarmed if you see compiler warnings originating in Boost
  322. headers. We try to eliminate them, but doing so isn't always
  323. practical.<a class="footnote-reference" href="#warnings" id="id6" name="id6"><sup>5</sup></a> <strong>Errors are another matter</strong>. If you're
  324. seeing compilation errors at this point in the tutorial, check to
  325. be sure you've copied the <a class="reference" href="#build-a-simple-program-using-boost">example program</a> correctly and that you've
  326. correctly identified the <a class="reference" href="#boost-root-directory">Boost root directory</a>.</p>
  327. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  328. <!-- Software License, Version 1.0. (See accompanying -->
  329. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  330. </div>
  331. </div>
  332. <div class="section">
  333. <h1><a class="toc-backref" href="#id28" id="prepare-to-use-a-boost-library-binary" name="prepare-to-use-a-boost-library-binary">5&nbsp;&nbsp;&nbsp;Prepare to Use a Boost Library Binary</a></h1>
  334. <p>If you want to use any of the separately-compiled Boost libraries,
  335. you'll need to acquire library binaries.</p>
  336. <div class="section">
  337. <h2><a class="toc-backref" href="#id29" id="install-visual-studio-2005-or-net-2003-binaries" name="install-visual-studio-2005-or-net-2003-binaries">5.1&nbsp;&nbsp;&nbsp;Install Visual Studio (2005 or .NET 2003) Binaries</a></h2>
  338. <p>The <a class="reference" href="http://www.boost-consulting.com/download/windows">installer</a> supplied by Boost Consulting will download and
  339. install pre-compiled binaries into the <tt class="docutils literal"><span class="pre">lib\</span></tt> subdirectory of the
  340. boost root, typically <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt><tt class="docutils literal"><span class="pre">\lib\</span></tt>. If you installed
  341. all variants of the <a class="reference" href="../../libs/regex/index.html">Boost.Regex</a> binary, you're done with this
  342. step. Otherwise, please run the installer again and install them
  343. now.</p>
  344. <p><a class="reference" href="#link-your-program-to-a-boost-library"><em>skip to the next step</em></a></p>
  345. </div>
  346. <div class="section">
  347. <h2><a class="toc-backref" href="#id30" id="or-build-and-install-binaries-from-source" name="or-build-and-install-binaries-from-source">5.2&nbsp;&nbsp;&nbsp;Or, Build and Install Binaries From Source</a></h2>
  348. <p>If you're using an earlier version of Visual C++, or a compiler
  349. from another vendor, you'll need to use <a class="reference" href="../../tools/build/index.html">Boost.Build</a> to create your
  350. own binaries.</p>
  351. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  352. <!-- Software License, Version 1.0. (See accompanying -->
  353. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  354. <p><a class="reference" href="../../tools/build/index.html">Boost.Build</a> is a text-based system for developing, testing, and
  355. installing software. To use it, you'll need an executable called
  356. <tt class="docutils literal"><span class="pre">bjam</span></tt>.</p>
  357. <div class="section">
  358. <h3><a class="toc-backref" href="#id31" id="get-bjam" name="get-bjam">5.2.1&nbsp;&nbsp;&nbsp;Get <tt class="docutils literal"><span class="pre">bjam</span></tt></a></h3>
  359. <p><tt class="docutils literal"><span class="pre">bjam</span></tt> is the <a class="reference" href="#command-line-tool">command-line tool</a> that drives the Boost Build
  360. system. To build Boost binaries, you'll invoke <tt class="docutils literal"><span class="pre">bjam</span></tt> from the
  361. Boost root.</p>
  362. <p>Boost provides <a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=7586&amp;package_id=72941">pre-compiled <tt class="docutils literal"><span class="pre">bjam</span></tt> executables</a> for a variety of platforms.
  363. Alternatively, you can build <tt class="docutils literal"><span class="pre">bjam</span></tt> yourself using <a class="reference" href="../../doc/html/jam/building.html">these
  364. instructions</a>.</p>
  365. </div>
  366. <div class="section">
  367. <h3><a class="toc-backref" href="#id32" id="identify-your-toolset" name="identify-your-toolset"><span id="toolset-name"></span><span id="toolset"></span>5.2.2&nbsp;&nbsp;&nbsp;Identify Your Toolset</a></h3>
  368. <p>First, find the toolset corresponding to your compiler in the
  369. following table.</p>
  370. <table border="1" class="docutils table">
  371. <colgroup>
  372. <col width="18%" />
  373. <col width="33%" />
  374. <col width="48%" />
  375. </colgroup>
  376. <thead valign="bottom">
  377. <tr><th class="head">Toolset
  378. Name</th>
  379. <th class="head">Vendor</th>
  380. <th class="head">Notes</th>
  381. </tr>
  382. </thead>
  383. <tbody valign="top">
  384. <tr><td><tt class="docutils literal"><span class="pre">acc</span></tt></td>
  385. <td>Hewlett Packard</td>
  386. <td>Only very recent versions are
  387. known to work well with Boost</td>
  388. </tr>
  389. <tr><td><tt class="docutils literal"><span class="pre">borland</span></tt></td>
  390. <td>Borland</td>
  391. <td>&nbsp;</td>
  392. </tr>
  393. <tr><td><tt class="docutils literal"><span class="pre">como</span></tt></td>
  394. <td>Comeau Computing</td>
  395. <td>Using this toolset may
  396. require <a class="reference" href="../../tools/build/index.html">configuring</a> another
  397. toolset to act as its backend</td>
  398. </tr>
  399. <tr><td><tt class="docutils literal"><span class="pre">cw</span></tt></td>
  400. <td>Metrowerks/FreeScale</td>
  401. <td>The CodeWarrior compiler. We
  402. have not tested versions of
  403. this compiler produced since
  404. it was sold to FreeScale.</td>
  405. </tr>
  406. <tr><td><tt class="docutils literal"><span class="pre">dmc</span></tt></td>
  407. <td>Digital Mars</td>
  408. <td>As of this Boost release, no
  409. version of dmc is known to
  410. handle Boost well.</td>
  411. </tr>
  412. <tr><td><tt class="docutils literal"><span class="pre">darwin</span></tt></td>
  413. <td>Apple Computer</td>
  414. <td>Apple's version of the GCC
  415. toolchain with support for
  416. Darwin and MacOS X features
  417. such as frameworks.</td>
  418. </tr>
  419. <tr><td><tt class="docutils literal"><span class="pre">gcc</span></tt></td>
  420. <td>The Gnu Project</td>
  421. <td>Includes support for Cygwin
  422. and MinGW compilers.</td>
  423. </tr>
  424. <tr><td><tt class="docutils literal"><span class="pre">hp_cxx</span></tt></td>
  425. <td>Hewlett Packard</td>
  426. <td>Targeted at the Tru64
  427. operating system.</td>
  428. </tr>
  429. <tr><td><tt class="docutils literal"><span class="pre">intel</span></tt></td>
  430. <td>Intel</td>
  431. <td>&nbsp;</td>
  432. </tr>
  433. <tr><td><tt class="docutils literal"><span class="pre">kylix</span></tt></td>
  434. <td>Borland</td>
  435. <td>&nbsp;</td>
  436. </tr>
  437. <tr><td><tt class="docutils literal"><span class="pre">msvc</span></tt></td>
  438. <td>Microsoft</td>
  439. <td>&nbsp;</td>
  440. </tr>
  441. <tr><td><tt class="docutils literal"><span class="pre">qcc</span></tt></td>
  442. <td>QNX Software Systems</td>
  443. <td>&nbsp;</td>
  444. </tr>
  445. <tr><td><tt class="docutils literal"><span class="pre">sun</span></tt></td>
  446. <td>Sun</td>
  447. <td>Only very recent versions are
  448. known to work well with
  449. Boost.</td>
  450. </tr>
  451. <tr><td><tt class="docutils literal"><span class="pre">vacpp</span></tt></td>
  452. <td>IBM</td>
  453. <td>The VisualAge C++ compiler.</td>
  454. </tr>
  455. </tbody>
  456. </table>
  457. <p>If you have multiple versions of a particular compiler installed,
  458. you can append the version number to the toolset name, preceded by a
  459. hyphen, e.g. <tt class="docutils literal"><span class="pre">msvc-7.1</span></tt> or <tt class="docutils literal"><span class="pre">gcc-3.4</span></tt>.</p>
  460. <div class="note">
  461. <p class="first admonition-title">Note</p>
  462. <p class="last">if you built <tt class="docutils literal"><span class="pre">bjam</span></tt> yourself, you may
  463. have selected a toolset name for that purpose, but that does not
  464. affect this step in any way; you still need to select a Boost.Build
  465. toolset from the table.</p>
  466. </div>
  467. </div>
  468. <div class="section">
  469. <h3><a class="toc-backref" href="#id33" id="select-a-build-directory" name="select-a-build-directory"><span id="id11"></span><span id="build-directory"></span>5.2.3&nbsp;&nbsp;&nbsp;Select a Build Directory</a></h3>
  470. <p><a class="reference" href="../../tools/build/index.html">Boost.Build</a> will place all intermediate files it generates while
  471. building into the <strong>build directory</strong>. If your Boost root
  472. directory is writable, this step isn't strictly necessary: by
  473. default Boost.Build will create a <tt class="docutils literal"><span class="pre">bin.v2/</span></tt> subdirectory for that
  474. purpose in your current working directory.</p>
  475. </div>
  476. <div class="section">
  477. <h3><a class="toc-backref" href="#id34" id="invoke-bjam" name="invoke-bjam">5.2.4&nbsp;&nbsp;&nbsp;Invoke <tt class="docutils literal"><span class="pre">bjam</span></tt></a></h3>
  478. <p>Change your current directory to the Boost root directory and
  479. invoke <tt class="docutils literal"><span class="pre">bjam</span></tt> as follows:</p>
  480. <pre class="literal-block">
  481. bjam <strong>--build-dir=</strong><a class="reference" href="#id11"><em>build-directory</em></a> <strong>--toolset=</strong><a class="reference" href="#toolset-name"><em>toolset-name</em></a> stage
  482. </pre>
  483. <p>For example, your session might look like this:<a class="footnote-reference" href="#continuation" id="id12" name="id12"><sup>4</sup></a></p>
  484. <pre class="literal-block">
  485. C:WINDOWS&gt; cd <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt>
  486. <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt>&gt; bjam <strong>^</strong>
  487. More? <strong>--build-dir=</strong>%TEMP%\build-boost <strong>^</strong>
  488. More? <strong>--toolset=</strong>msvc stage
  489. </pre>
  490. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  491. <!-- Software License, Version 1.0. (See accompanying -->
  492. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  493. <p>Boost.Build will place the Boost binaries in the <tt class="docutils literal"><span class="pre">stage</span></tt><tt class="docutils literal"><span class="pre">\</span></tt>
  494. subdirectory of your <a class="reference" href="#build-directory">build directory</a>.</p>
  495. <div class="note">
  496. <p class="first admonition-title">Note</p>
  497. <p class="last"><tt class="docutils literal"><span class="pre">bjam</span></tt> is case-sensitive; it is important that all the
  498. parts shown in <strong>bold</strong> type above be entirely lower-case.</p>
  499. </div>
  500. <p>For a description of other options you can pass when invoking
  501. <tt class="docutils literal"><span class="pre">bjam</span></tt>, type:</p>
  502. <pre class="literal-block">
  503. bjam --help
  504. </pre>
  505. <p>In particular, to limit the amount of time spent building, you may
  506. be interested in:</p>
  507. <ul class="simple">
  508. <li>reviewing the list of library names with <tt class="docutils literal"><span class="pre">--show-libraries</span></tt></li>
  509. <li>limiting which libraries get built with the <tt class="docutils literal"><span class="pre">--with-</span></tt><em>library-name</em> or <tt class="docutils literal"><span class="pre">--without-</span></tt><em>library-name</em> options</li>
  510. <li>choosing a specific build variant by adding <tt class="docutils literal"><span class="pre">release</span></tt> or
  511. <tt class="docutils literal"><span class="pre">debug</span></tt> to the command line.</li>
  512. </ul>
  513. </div>
  514. </div>
  515. <div class="section">
  516. <h2><a class="toc-backref" href="#id35" id="expected-build-output" name="expected-build-output">5.3&nbsp;&nbsp;&nbsp;Expected Build Output</a></h2>
  517. <p>During the process of building Boost libraries, you can expect to
  518. see some messages printed on the console. These may include</p>
  519. <ul>
  520. <li><p class="first">Notices about Boost library configuration—for example, the Regex
  521. library outputs a message about ICU when built without Unicode
  522. support, and the Python library may be skipped without error (but
  523. with a notice) if you don't have Python installed.</p>
  524. </li>
  525. <li><p class="first">Messages from the build tool that report the number of targets
  526. that were built or skipped. Don't be surprised if those numbers
  527. don't make any sense to you; there are many targets per library.</p>
  528. </li>
  529. <li><p class="first">Build action messages describing what the tool is doing, which
  530. look something like:</p>
  531. <pre class="literal-block">
  532. <em>toolset-name</em>.c++ <em>long</em>/<em>path</em>/<em>to</em>/<em>file</em>/<em>being</em>/<em>built</em>
  533. </pre>
  534. </li>
  535. <li><p class="first">Compiler warnings.</p>
  536. </li>
  537. </ul>
  538. </div>
  539. <div class="section">
  540. <h2><a class="toc-backref" href="#id36" id="in-case-of-build-errors" name="in-case-of-build-errors">5.4&nbsp;&nbsp;&nbsp;In Case of Build Errors</a></h2>
  541. <p>The only error messages you see when building Boost—if any—should
  542. be related to the IOStreams library's support of zip and bzip2
  543. formats as described <a class="reference" href="../../libs/iostreams/doc/installation.html">here</a>. Install the relevant development
  544. packages for libz and libbz2 if you need those features. Other
  545. errors when building Boost libraries are cause for concern.</p>
  546. <p>If it seems like the build system can't find your compiler and/or
  547. linker, consider setting up a <tt class="docutils literal"><span class="pre">user-config.jam</span></tt> file as described
  548. in the <a class="reference" href="../../tools/build/index.html">Boost.Build documentation</a>. If that isn't your problem or
  549. the <tt class="docutils literal"><span class="pre">user-config.jam</span></tt> file doesn't work for you, please address
  550. questions about configuring Boost for your compiler to the
  551. <a class="reference" href="../../more/mailing_lists.htm#jamboost">Boost.Build mailing list</a>.</p>
  552. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  553. <!-- Software License, Version 1.0. (See accompanying -->
  554. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  555. </div>
  556. </div>
  557. <div class="section">
  558. <h1><a class="toc-backref" href="#id37" id="link-your-program-to-a-boost-library" name="link-your-program-to-a-boost-library">6&nbsp;&nbsp;&nbsp;Link Your Program to a Boost Library</a></h1>
  559. <p>To demonstrate linking with a Boost binary library, we'll use the
  560. following simple program that extracts the subject lines from
  561. emails. It uses the <a class="reference" href="../../libs/regex/index.html">Boost.Regex</a> library, which has a
  562. separately-compiled binary component.</p>
  563. <pre class="literal-block">
  564. #include &lt;boost/regex.hpp&gt;
  565. #include &lt;iostream&gt;
  566. #include &lt;string&gt;
  567. int main()
  568. {
  569. std::string line;
  570. boost::regex pat( &quot;^Subject: (Re: |Aw: )*(.*)&quot; );
  571. while (std::cin)
  572. {
  573. std::getline(std::cin, line);
  574. boost::smatch matches;
  575. if (boost::regex_match(line, matches, pat))
  576. std::cout &lt;&lt; matches[2] &lt;&lt; std::endl;
  577. }
  578. }
  579. </pre>
  580. <p>There are two main challenges associated with linking:</p>
  581. <ol class="arabic simple">
  582. <li>Tool configuration, e.g. choosing command-line options or IDE
  583. build settings.</li>
  584. <li>Identifying the library binary, among all the build variants,
  585. whose compile configuration is compatible with the rest of your
  586. project.</li>
  587. </ol>
  588. <div class="admonition-auto-linking admonition">
  589. <p class="first admonition-title">Auto-Linking</p>
  590. <p class="last">Most Windows compilers and linkers have so-called “auto-linking
  591. support,” which eliminates the second challenge. Special code in
  592. Boost header files detects your compiler options and uses that
  593. information to encode the name of the correct library into your
  594. object files; the linker selects the library with that name from
  595. the directories you've told it to search.</p>
  596. </div>
  597. <div class="section">
  598. <h2><a class="toc-backref" href="#id38" id="link-from-within-the-visual-studio-ide" name="link-from-within-the-visual-studio-ide">6.1&nbsp;&nbsp;&nbsp;Link From Within the Visual Studio IDE</a></h2>
  599. <p>Starting with the <a class="reference" href="#vs-header-only">header-only example project</a> we created
  600. earlier:</p>
  601. <ol class="arabic simple">
  602. <li>Right-click <strong>example</strong> in the <em>Solution Explorer</em> pane and
  603. select <em>Properties</em> from the resulting pop-up menu</li>
  604. <li>In <em>Configuration Properties</em> &gt; <em>Linker</em> &gt; <em>Additional Library
  605. Directories</em>, enter the path to the Boost binaries,
  606. e.g. <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt><tt class="docutils literal"><span class="pre">\lib\</span></tt>.</li>
  607. <li>From the <em>Build</em> menu, select <em>Build Solution</em>.</li>
  608. </ol>
  609. <p><a class="reference" href="#test-your-program"><em>skip to the next step</em></a></p>
  610. </div>
  611. <div class="section">
  612. <h2><a class="toc-backref" href="#id39" id="or-link-from-the-command-prompt" name="or-link-from-the-command-prompt">6.2&nbsp;&nbsp;&nbsp;Or, Link From the Command Prompt</a></h2>
  613. <p>For example, we can compile and link the above program from the
  614. Visual C++ command-line by simply adding the <strong>bold</strong> text below to
  615. the command line we used earlier, assuming your Boost binaries are
  616. in <tt class="docutils literal"><span class="pre">C:\Program</span> <span class="pre">Files\boost\</span></tt><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt><tt class="docutils literal"><span class="pre">\lib</span></tt>:</p>
  617. <pre class="literal-block">
  618. cl /EHsc /I <em>path\to\</em><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt> example.cpp <strong>^</strong>
  619. <strong>/link /LIBPATH:</strong> <strong>C:\Program Files\boost\</strong><strong>boost_1_34_0</strong><strong>\lib</strong>
  620. </pre>
  621. </div>
  622. <div class="section">
  623. <h2><a class="toc-backref" href="#id40" id="library-naming" name="library-naming">6.3&nbsp;&nbsp;&nbsp;Library Naming</a></h2>
  624. <div class="note">
  625. <p class="first admonition-title">Note</p>
  626. <p>If, like Visual C++, your compiler supports auto-linking,
  627. you can probably <a class="reference" href="#test-your-program"><em>skip to the next step</em></a>.</p>
  628. <blockquote class="last">
  629. </blockquote>
  630. </div>
  631. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  632. <!-- Software License, Version 1.0. (See accompanying -->
  633. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  634. <p>In order to choose the right binary for your build configuration
  635. you need to know how Boost binaries are named. Each library
  636. filename is composed of a common sequence of elements that describe
  637. how it was built. For example,
  638. <tt class="docutils literal"><span class="pre">libboost_regex-vc71-mt-d-1_34.lib</span></tt> can be broken down into the
  639. following elements:</p>
  640. <dl class="docutils">
  641. <dt><tt class="docutils literal"><span class="pre">lib</span></tt></dt>
  642. <dd><em>Prefix</em>: except on Microsoft Windows, every Boost library
  643. name begins with this string. On Windows, only ordinary static
  644. libraries use the <tt class="docutils literal"><span class="pre">lib</span></tt> prefix; import libraries and DLLs do
  645. not.<a class="footnote-reference" href="#distinct" id="id17" name="id17"><sup>6</sup></a></dd>
  646. <dt><tt class="docutils literal"><span class="pre">boost_regex</span></tt></dt>
  647. <dd><em>Library name</em>: all boost library filenames begin with <tt class="docutils literal"><span class="pre">boost_</span></tt>.</dd>
  648. <dt><tt class="docutils literal"><span class="pre">-vc71</span></tt></dt>
  649. <dd><em>Toolset tag</em>: identifies the toolset and version used to build
  650. the binary.</dd>
  651. <dt><tt class="docutils literal"><span class="pre">-mt</span></tt></dt>
  652. <dd><em>Threading tag</em>: indicates that the library was
  653. built with multithreading support enabled. Libraries built
  654. without multithreading support can be identified by the absence
  655. of <tt class="docutils literal"><span class="pre">-mt</span></tt>.</dd>
  656. <dt><tt class="docutils literal"><span class="pre">-d</span></tt></dt>
  657. <dd><p class="first"><em>ABI tag</em>: encodes details that affect the library's
  658. interoperability with other compiled code. For each such
  659. feature, a single letter is added to the tag:</p>
  660. <blockquote>
  661. <table border="1" class="docutils table">
  662. <colgroup>
  663. <col width="6%" />
  664. <col width="94%" />
  665. </colgroup>
  666. <thead valign="bottom">
  667. <tr><th class="head">Key</th>
  668. <th class="head">Use this library when:</th>
  669. </tr>
  670. </thead>
  671. <tbody valign="top">
  672. <tr><td><tt class="docutils literal"><span class="pre">s</span></tt></td>
  673. <td>linking statically to the C++ standard library and compiler runtime support
  674. libraries.</td>
  675. </tr>
  676. <tr><td><tt class="docutils literal"><span class="pre">g</span></tt></td>
  677. <td>using debug versions of the standard and runtime support libraries.</td>
  678. </tr>
  679. <tr><td><tt class="docutils literal"><span class="pre">y</span></tt></td>
  680. <td>using a special <a class="reference" href="../../libs/python/doc/building.html#variants">debug build of Python</a>.</td>
  681. </tr>
  682. <tr><td><tt class="docutils literal"><span class="pre">d</span></tt></td>
  683. <td>building a debug version of your code.<a class="footnote-reference" href="#debug-abi" id="id18" name="id18"><sup>7</sup></a></td>
  684. </tr>
  685. <tr><td><tt class="docutils literal"><span class="pre">p</span></tt></td>
  686. <td>using the STLPort standard library rather than the default one supplied with
  687. your compiler.</td>
  688. </tr>
  689. <tr><td><tt class="docutils literal"><span class="pre">n</span></tt></td>
  690. <td>using STLPort's deprecated “native iostreams” feature.<a class="footnote-reference" href="#native" id="id19" name="id19"><sup>8</sup></a></td>
  691. </tr>
  692. </tbody>
  693. </table>
  694. </blockquote>
  695. <p class="last">For example, if you build a debug version of your code for use
  696. with debug versions of the static runtime library and the
  697. STLPort standard library in “native iostreams” mode,
  698. the tag would be: <tt class="docutils literal"><span class="pre">-sgdpn</span></tt>. If none of the above apply, the
  699. ABI tag is ommitted.</p>
  700. </dd>
  701. <dt><tt class="docutils literal"><span class="pre">-1_34</span></tt></dt>
  702. <dd><em>Version tag</em>: the full Boost release number, with periods
  703. replaced by underscores. For example, version 1.31.1 would be
  704. tagged as &quot;-1_31_1&quot;.</dd>
  705. <dt><tt class="docutils literal"><span class="pre">.lib</span></tt></dt>
  706. <dd><em>Extension</em>: determined according to the operating system's usual
  707. convention. On most unix-style platforms the extensions are
  708. <tt class="docutils literal"><span class="pre">.a</span></tt> and <tt class="docutils literal"><span class="pre">.so</span></tt> for static libraries (archives) and shared
  709. libraries, respectively. On Windows, <tt class="docutils literal"><span class="pre">.dll</span></tt> indicates a shared
  710. library and (except for static libraries built by the <tt class="docutils literal"><span class="pre">gcc</span></tt>
  711. toolset, whose names always end in <tt class="docutils literal"><span class="pre">.a</span></tt>) <tt class="docutils literal"><span class="pre">.lib</span></tt> indicates a
  712. static or import library. Where supported by toolsets on unix
  713. variants, a full version extension is added (e.g. &quot;.so.1.34&quot;) and
  714. a symbolic link to the library file, named without the trailing
  715. version number, will also be created.</dd>
  716. </dl>
  717. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  718. <!-- Software License, Version 1.0. (See accompanying -->
  719. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  720. </div>
  721. <div class="section">
  722. <h2><a class="toc-backref" href="#id41" id="test-your-program" name="test-your-program">6.4&nbsp;&nbsp;&nbsp;Test Your Program</a></h2>
  723. <p>To test our subject extraction, we'll filter the following text
  724. file. Copy it out of your browser and save it as <tt class="docutils literal"><span class="pre">jayne.txt</span></tt>:</p>
  725. <pre class="literal-block">
  726. To: George Shmidlap
  727. From: Rita Marlowe
  728. Subject: Will Success Spoil Rock Hunter?
  729. ---
  730. See subject.
  731. </pre>
  732. <p>Now, in a <a class="reference" href="#command-prompt">command prompt</a> window, type:</p>
  733. <pre class="literal-block">
  734. <em>path</em>\<em>to</em>\<em>compiled</em>\example &lt; <em>path</em>\<em>to</em>\jayne.txt
  735. </pre>
  736. <p>The program should respond with the email subject, “Will Success
  737. Spoil Rock Hunter?”</p>
  738. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  739. <!-- Software License, Version 1.0. (See accompanying -->
  740. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  741. </div>
  742. </div>
  743. <div class="section">
  744. <h1><a class="toc-backref" href="#id42" id="conclusion-and-further-resources" name="conclusion-and-further-resources">7&nbsp;&nbsp;&nbsp;Conclusion and Further Resources</a></h1>
  745. <p>This concludes your introduction to Boost and to integrating it
  746. with your programs. As you start using Boost in earnest, there are
  747. surely a few additional points you'll wish we had covered. One day
  748. we may have a “Book 2 in the Getting Started series” that addresses
  749. them. Until then, we suggest you pursue the following resources.
  750. If you can't find what you need, or there's anything we can do to
  751. make this document clearer, please post it to the <a class="reference" href="../../more/mailing_lists.htm#users">Boost Users'
  752. mailing list</a>.</p>
  753. <ul class="simple">
  754. <li><a class="reference" href="../../tools/build/v2">Boost.Build reference manual</a></li>
  755. <li><a class="reference" href="../../tools/jam/index.html">Boost.Jam reference manual</a></li>
  756. <li><a class="reference" href="../../more/mailing_lists.htm#users">Boost Users' mailing list</a></li>
  757. <li><a class="reference" href="../../more/mailing_lists.htm#jamboost">Boost.Build mailing list</a></li>
  758. <li><a class="reference" href="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Boost.Build_V2">Boost.Build Wiki</a></li>
  759. <li><a class="reference" href="../../libs/index.html">Index of all Boost library documentation</a></li>
  760. </ul>
  761. <div class="admonition-onward admonition">
  762. <p class="first admonition-title">Onward</p>
  763. <blockquote class="epigraph last">
  764. <p>Good luck, and have fun!</p>
  765. <p class="attribution">&mdash;the Boost Developers</p>
  766. </blockquote>
  767. </div>
  768. <hr class="docutils" />
  769. <table class="docutils footnote" frame="void" id="zip" rules="none">
  770. <colgroup><col class="label" /><col /></colgroup>
  771. <tbody valign="top">
  772. <tr><td class="label"><a class="fn-backref" href="#id2" name="zip">[1]</a></td><td>If you prefer not to download executable programs,
  773. download <a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=7586&amp;package_id=8041&amp;release_id=376197"><tt class="docutils literal"><span class="pre">boost_1_34_0</span></tt><tt class="docutils literal"><span class="pre">.zip</span></tt></a> and use an external tool to decompress
  774. it. We don't recommend using Windows' built-in decompression as
  775. it can be painfully slow for large archives.</td></tr>
  776. </tbody>
  777. </table>
  778. <table class="docutils footnote" frame="void" id="installer-src" rules="none">
  779. <colgroup><col class="label" /><col /></colgroup>
  780. <tbody valign="top">
  781. <tr><td class="label"><a name="installer-src">[2]</a></td><td>If you used the <a class="reference" href="http://www.boost-consulting.com/download/windows">installer</a> from Boost
  782. Consulting and deselected “Source and Documentation” (it's
  783. selected by default), you won't see the <tt class="docutils literal"><span class="pre">libs/</span></tt> subdirectory.
  784. That won't affect your ability to use precompiled binaries, but
  785. you won't be able to rebuild libraries from scratch.</td></tr>
  786. </tbody>
  787. </table>
  788. <table class="docutils footnote" frame="void" id="pch" rules="none">
  789. <colgroup><col class="label" /><col /></colgroup>
  790. <tbody valign="top">
  791. <tr><td class="label"><a class="fn-backref" href="#id4" name="pch">[3]</a></td><td>There's no problem using Boost with precompiled headers;
  792. these instructions merely avoid precompiled headers because it
  793. would require Visual Studio-specific changes to the source code
  794. used in the examples.</td></tr>
  795. </tbody>
  796. </table>
  797. <table class="docutils footnote" frame="void" id="continuation" rules="none">
  798. <colgroup><col class="label" /><col /></colgroup>
  799. <tbody valign="top">
  800. <tr><td class="label"><a class="fn-backref" href="#id12" name="continuation">[4]</a></td><td>In this example, the caret character <tt class="docutils literal"><span class="pre">^</span></tt> is a
  801. way of continuing the command on multiple lines. The command
  802. prompt responds with <tt class="docutils literal"><span class="pre">More?</span></tt> to prompt for more input. Feel
  803. free to omit the carets and subsequent newlines; we used them so
  804. the example would fit on a page of reasonable width.</td></tr>
  805. </tbody>
  806. </table>
  807. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  808. <!-- Software License, Version 1.0. (See accompanying -->
  809. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  810. <table class="docutils footnote" frame="void" id="warnings" rules="none">
  811. <colgroup><col class="label" /><col /></colgroup>
  812. <tbody valign="top">
  813. <tr><td class="label"><a class="fn-backref" href="#id6" name="warnings">[5]</a></td><td>Remember that warnings are specific to each compiler
  814. implementation. The developer of a given Boost library might
  815. not have access to your compiler. Also, some warnings are
  816. extremely difficult to eliminate in generic code, to the point
  817. where it's not worth the trouble. Finally, some compilers don't
  818. have any source code mechanism for suppressing warnings.</td></tr>
  819. </tbody>
  820. </table>
  821. <table class="docutils footnote" frame="void" id="distinct" rules="none">
  822. <colgroup><col class="label" /><col /></colgroup>
  823. <tbody valign="top">
  824. <tr><td class="label"><a class="fn-backref" href="#id17" name="distinct">[6]</a></td><td>This convention distinguishes the static version of
  825. a Boost library from the import library for an
  826. identically-configured Boost DLL, which would otherwise have the
  827. same name.</td></tr>
  828. </tbody>
  829. </table>
  830. <table class="docutils footnote" frame="void" id="debug-abi" rules="none">
  831. <colgroup><col class="label" /><col /></colgroup>
  832. <tbody valign="top">
  833. <tr><td class="label"><a class="fn-backref" href="#id18" name="debug-abi">[7]</a></td><td>These libraries were compiled without optimization
  834. or inlining, with full debug symbols enabled, and without
  835. <tt class="docutils literal"><span class="pre">NDEBUG</span></tt> <tt class="docutils literal"><span class="pre">#define</span></tt>d. Although it's true that sometimes
  836. these choices don't affect binary compatibility with other
  837. compiled code, you can't count on that with Boost libraries.</td></tr>
  838. </tbody>
  839. </table>
  840. <table class="docutils footnote" frame="void" id="native" rules="none">
  841. <colgroup><col class="label" /><col /></colgroup>
  842. <tbody valign="top">
  843. <tr><td class="label"><a class="fn-backref" href="#id19" name="native">[8]</a></td><td>This feature of STLPort is deprecated because it's
  844. impossible to make it work transparently to the user; we don't
  845. recommend it.</td></tr>
  846. </tbody>
  847. </table>
  848. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  849. <!-- Software License, Version 1.0. (See accompanying -->
  850. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  851. <!-- This file contains all the definitions that need to be updated -->
  852. <!-- for each new release of Boost. -->
  853. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  854. <!-- Software License, Version 1.0. (See accompanying -->
  855. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  856. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  857. <!-- Software License, Version 1.0. (See accompanying -->
  858. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  859. <!-- Copyright David Abrahams 2006. Distributed under the Boost -->
  860. <!-- Software License, Version 1.0. (See accompanying -->
  861. <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
  862. </div>
  863. </div>
  864. </body>
  865. </html>
粤ICP备19079148号