prebuilt.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  4. <title>Prebuilt targets</title>
  5. <link rel="stylesheet" href="../../boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
  7. <style type="text/css">
  8. body { background-image: url('http://docbook.sourceforge.net/release/images/draft.png');
  9. background-repeat: no-repeat;
  10. background-position: top left;
  11. /* The following properties make the watermark "fixed" on the page. */
  12. /* I think that's just a bit too distracting for the reader... */
  13. /* background-attachment: fixed; */
  14. /* background-position: center center; */
  15. }</style>
  16. <link rel="start" href="../../index.html" title="The Boost C++ Libraries">
  17. <link rel="up" href="../tutorial.html" title="Chapter 23. Tutorial">
  18. <link rel="prev" href="conditions.html" title="Conditions and alternatives">
  19. <link rel="next" href="../advanced.html" title="Chapter 24. User documentation">
  20. </head>
  21. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  22. <table cellpadding="2" width="100%">
  23. <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../boost.png"></td>
  24. <td align="center"><a href="../../../../index.htm">Home</a></td>
  25. <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
  26. <td align="center"><a href="../../../../people/people.htm">People</a></td>
  27. <td align="center"><a href="../../../../more/faq.htm">FAQ</a></td>
  28. <td align="center"><a href="../../../../more/index.htm">More</a></td>
  29. </table>
  30. <hr>
  31. <div class="spirit-nav">
  32. <a accesskey="p" href="conditions.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../advanced.html"><img src="../../images/next.png" alt="Next"></a>
  33. </div>
  34. <div class="section" lang="en">
  35. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  36. <a name="bbv2.tutorial.prebuilt"></a>Prebuilt targets</h2></div></div></div>
  37. <p>
  38. To link to libraries whose build instructions aren't given in a Jamfile,
  39. you need to create <code class="computeroutput">lib</code> targets with an appropriate
  40. <code class="varname">file</code> property. Target alternatives can be used to
  41. associate multiple library files with a single conceptual target. For
  42. example:
  43. </p>
  44. <pre class="programlisting">
  45. # util/lib2/Jamfile
  46. lib lib2
  47. :
  48. : &lt;file&gt;lib2_release.a &lt;variant&gt;release
  49. ;
  50. lib lib2
  51. :
  52. : &lt;file&gt;lib2_debug.a &lt;variant&gt;debug
  53. ;
  54. </pre>
  55. <p>
  56. This example defines two alternatives for <code class="filename">lib2</code>, and
  57. for each one names a prebuilt file. Naturally, there are no sources.
  58. Instead, the <code class="varname">&lt;file&gt;</code> feature is used to specify
  59. the file name.
  60. </p>
  61. <p>
  62. Once a prebuilt target has been declared, it can be used just like any other target:
  63. </p>
  64. <pre class="programlisting">
  65. exe app : app.cpp ../util/lib2//lib2 ;
  66. </pre>
  67. <p>
  68. As with any target, the alternative selected depends on the
  69. properties propagated from <code class="filename">lib2</code>'s dependents.
  70. If we build the the release and debug versions of <code class="filename">app</code> will be linked
  71. with <code class="filename">lib2_release.a</code> and <code class="filename">lib2_debug.a</code>, respectively.
  72. </p>
  73. <p>
  74. System libraries&#8212;those that are automatically found by
  75. the toolset by searching through some set of predetermined
  76. paths&#8212;should be declared almost like regular ones:
  77. </p>
  78. <pre class="programlisting">
  79. lib pythonlib : : &lt;name&gt;python22 ;
  80. </pre>
  81. <p>
  82. We again don't specify any sources, but give a
  83. <code class="varname">name</code> that should be passed to the
  84. compiler. If the gcc toolset were used to link an executable
  85. target to <code class="filename">pythonlib</code>, <code class="option">-lpython22</code>
  86. would appear in the command line (other compilers may use
  87. different options).
  88. </p>
  89. <p>
  90. We can also specify where the toolset should look for the library:
  91. </p>
  92. <pre class="programlisting">
  93. lib pythonlib : : &lt;name&gt;python22 &lt;search&gt;/opt/lib ;
  94. </pre>
  95. <p>
  96. And, of course, target alternatives can be used in the usual way:
  97. </p>
  98. <pre class="programlisting">
  99. lib pythonlib : : &lt;name&gt;python22 &lt;variant&gt;release ;
  100. lib pythonlib : : &lt;name&gt;python22_d &lt;variant&gt;debug ;
  101. </pre>
  102. <p>A more advanced use of prebuilt targets is described in <a href="../recipies/site-config.html" title="Targets in site-config.jam">the section called &#8220;Targets in site-config.jam&#8221;</a>.
  103. </p>
  104. </div>
  105. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  106. <td align="left"></td>
  107. <td align="right"><small></small></td>
  108. </tr></table>
  109. <hr>
  110. <div class="spirit-nav">
  111. <a accesskey="p" href="conditions.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../advanced.html"><img src="../../images/next.png" alt="Next"></a>
  112. </div>
  113. </body>
  114. </html>
粤ICP备19079148号