building.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>If and How to Build a Boost.Math Library, and its Examples and Tests</title>
  5. <link rel="stylesheet" href="../math.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../index.html" title="Math Toolkit 2.11.0">
  8. <link rel="up" href="../overview.html" title="Chapter&#160;1.&#160;Overview">
  9. <link rel="prev" href="perf_over1.html" title="Performance">
  10. <link rel="next" href="history1.html" title="History and What's New">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="perf_over1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="history1.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  27. <a name="math_toolkit.building"></a><a class="link" href="building.html" title="If and How to Build a Boost.Math Library, and its Examples and Tests">If and How to Build a Boost.Math
  28. Library, and its Examples and Tests</a>
  29. </h2></div></div></div>
  30. <h5>
  31. <a name="math_toolkit.building.h0"></a>
  32. <span class="phrase"><a name="math_toolkit.building.building_a_library_shared_dynami"></a></span><a class="link" href="building.html#math_toolkit.building.building_a_library_shared_dynami">Building a
  33. Library (shared, dynamic .dll or static .lib)</a>
  34. </h5>
  35. <p>
  36. The first thing you need to ask yourself is "Do I need to build anything
  37. at all?" as the bulk of this library is header only: meaning you can use
  38. it just by #including the necessary header(s).
  39. </p>
  40. <p>
  41. For most simple uses, including a header (or few) is best for compile time
  42. and program size.
  43. </p>
  44. <p>
  45. Refer to <a class="link" href="../extern_c.html" title='Chapter&#160;9.&#160;TR1 and C99 external "C" Functions'>C99 and C++ TR1 C-style Functions</a>
  46. for pros and cons of using the TR1 components as opposed to the header only
  47. ones.
  48. </p>
  49. <p>
  50. The <span class="emphasis"><em>only</em></span> time you <span class="emphasis"><em>need</em></span> to build the
  51. library is if you want to use the <code class="computeroutput"><span class="keyword">extern</span>
  52. <span class="string">"C"</span></code> functions declared in
  53. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">tr1</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>. To build this using Boost.Build, from
  54. a command-line boost-root directory issue a command like:
  55. </p>
  56. <pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span> <span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">math</span> <span class="identifier">install</span>
  57. </pre>
  58. <p>
  59. that will do the job on Linux, while:
  60. </p>
  61. <pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">msvc</span> <span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">math</span> <span class="special">--</span><span class="identifier">build</span><span class="special">-</span><span class="identifier">type</span><span class="special">=</span><span class="identifier">complete</span> <span class="identifier">stage</span>
  62. </pre>
  63. <p>
  64. will work better on Windows (leaving libraries built in sub-folder <code class="computeroutput"><span class="special">/</span><span class="identifier">stage</span></code> below
  65. your Boost root directory). Either way you should consult the <a href="http://www.boost.org/doc/libs/release/more/getting_started/index.html" target="_top">getting
  66. started guide</a> for more information.
  67. </p>
  68. <p>
  69. You can also build the libraries from your favourite IDE or command line tool:
  70. each <code class="computeroutput"><span class="keyword">extern</span> <span class="string">"C"</span></code>
  71. function declared in <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">tr1</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> has its own source file with the same name
  72. in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">src</span><span class="special">/</span><span class="identifier">tr1</span></code>. Just
  73. select the sources corresponding to the functions you are using and build them
  74. into a library, or else add them directly to your project. Note that the directory
  75. <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">src</span><span class="special">/</span><span class="identifier">tr1</span></code> will
  76. need to be in your compiler's #include path as well as the boost-root directory
  77. (MSVC Tools, Options, Projects and Solutions, VC++ Directories, Include files).
  78. </p>
  79. <div class="note"><table border="0" summary="Note">
  80. <tr>
  81. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
  82. <th align="left">Note</th>
  83. </tr>
  84. <tr><td align="left" valign="top"><p>
  85. If you are using a Windows compiler that supports auto-linking and you have
  86. built the sources yourself (or added them directly to your project) then
  87. you will need to prevent <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">tr1</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
  88. from trying to auto-link to the binaries that Boost.Build generates. You
  89. can do this by defining either BOOST_MATH_NO_LIB or BOOST_ALL_NO_LIB at project
  90. level (so the defines get passed to each compiler invocation).
  91. </p></td></tr>
  92. </table></div>
  93. <p>
  94. Optionally the sources in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">src</span><span class="special">/</span><span class="identifier">tr1</span></code>
  95. have support for using <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">src</span><span class="special">/</span><span class="identifier">tr1</span><span class="special">/</span><span class="identifier">pch</span><span class="special">.</span><span class="identifier">hpp</span></code> as a precompiled header <span class="emphasis"><em>if
  96. your compiler supports precompiled headers.</em></span> Note that normally this
  97. header is a do-nothing <code class="computeroutput"><span class="preprocessor">#include</span></code>
  98. to activate the header so that it #includes everything required by all the
  99. sources you will need to define BOOST_BUILD_PCH_ENABLED on the command line,
  100. both when building the pre-compiled header and when building the sources. Boost.Build
  101. will do this automatically when appropriate.
  102. </p>
  103. <h5>
  104. <a name="math_toolkit.building.h1"></a>
  105. <span class="phrase"><a name="math_toolkit.building.building_the_examples"></a></span><a class="link" href="building.html#math_toolkit.building.building_the_examples">Building
  106. the Examples</a>
  107. </h5>
  108. <p>
  109. The examples are all located in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">example</span></code>, they can all be built without reference
  110. to any external libraries, either with Boost.Build using the supplied Jamfile,
  111. or from your compiler's command line. The only requirement is that the Boost
  112. headers are in your compilers #include search path.
  113. </p>
  114. <h5>
  115. <a name="math_toolkit.building.h2"></a>
  116. <span class="phrase"><a name="math_toolkit.building.building_the_tests"></a></span><a class="link" href="building.html#math_toolkit.building.building_the_tests">Building
  117. the Tests</a>
  118. </h5>
  119. <p>
  120. The tests are located in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">test</span></code> and are best built using Boost.Build
  121. and the supplied Jamfile. If you plan to build them separately from your favourite
  122. IDE then you will need to add <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">test</span></code> to the list of your compiler's search
  123. paths.
  124. </p>
  125. <p>
  126. You will also need to build and link to the Boost.Regex library for many of
  127. the tests: this can built from the command line by following the <a href="http://www.boost.org/doc/libs/release/more/getting_started/index.html" target="_top">getting
  128. started guide</a>, using commands such as:
  129. </p>
  130. <pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">toolset</span><span class="special">=</span><span class="identifier">gcc</span> <span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">regex</span> <span class="identifier">install</span>
  131. </pre>
  132. <p>
  133. or bjam toolset=clang --with-regex install or bjam toolset=gcc,clang --with-regex
  134. install or bjam toolset=msvc --with-regex --build-type=complete stage
  135. </p>
  136. <p>
  137. depending on whether you are on Linux or Windows.
  138. </p>
  139. <p>
  140. Many of the tests have optional precompiled header support using the header
  141. <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">pch</span><span class="special">.</span><span class="identifier">hpp</span></code>. Note that normally this header is a
  142. do-nothing include: to activate the header so that it <code class="computeroutput"><span class="preprocessor">#include</span></code>s
  143. everything required by all the sources you will need to define BOOST_BUILD_PCH_ENABLED
  144. on the command line, both when building the pre-compiled header and when building
  145. the sources. Boost.Build will do this automatically when appropriate.
  146. </p>
  147. </div>
  148. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  149. <td align="left"></td>
  150. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  151. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  152. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  153. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  154. Daryle Walker and Xiaogang Zhang<p>
  155. Distributed under the Boost Software License, Version 1.0. (See accompanying
  156. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  157. </p>
  158. </div></td>
  159. </tr></table>
  160. <hr>
  161. <div class="spirit-nav">
  162. <a accesskey="p" href="perf_over1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="history1.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  163. </div>
  164. </body>
  165. </html>