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.69.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 | : <file>lib2_release.a <variant>release |
---|
49 | ; |
---|
50 | |
---|
51 | lib lib2 |
---|
52 | : |
---|
53 | : <file>lib2_debug.a <variant>debug |
---|
54 | ; |
---|
55 | </pre> |
---|
56 | <p> |
---|
57 | |
---|
58 | This example defines two alternatives for <code class="filename">lib2</code>, and |
---|
59 | for each one names a prebuilt file. Naturally, there are no sources. |
---|
60 | Instead, the <code class="varname"><file></code> feature is used to specify |
---|
61 | the file name. |
---|
62 | </p> |
---|
63 | <p> |
---|
64 | Once a prebuilt target has been declared, it can be used just like any other target: |
---|
65 | |
---|
66 | </p> |
---|
67 | <pre class="programlisting"> |
---|
68 | exe app : app.cpp ../util/lib2//lib2 ; |
---|
69 | </pre> |
---|
70 | <p> |
---|
71 | |
---|
72 | As with any target, the alternative selected depends on the |
---|
73 | properties propagated from <code class="filename">lib2</code>'s dependents. |
---|
74 | If we build the the release and debug versions of <code class="filename">app</code> will be linked |
---|
75 | with <code class="filename">lib2_release.a</code> and <code class="filename">lib2_debug.a</code>, respectively. |
---|
76 | |
---|
77 | </p> |
---|
78 | <p> |
---|
79 | System libraries—those that are automatically found by |
---|
80 | the toolset by searching through some set of predetermined |
---|
81 | paths—should be declared almost like regular ones: |
---|
82 | |
---|
83 | </p> |
---|
84 | <pre class="programlisting"> |
---|
85 | lib pythonlib : : <name>python22 ; |
---|
86 | </pre> |
---|
87 | <p> |
---|
88 | |
---|
89 | We again don't specify any sources, but give a |
---|
90 | <code class="varname">name</code> that should be passed to the |
---|
91 | compiler. If the gcc toolset were used to link an executable |
---|
92 | target to <code class="filename">pythonlib</code>, <code class="option">-lpython22</code> |
---|
93 | would appear in the command line (other compilers may use |
---|
94 | different options). |
---|
95 | </p> |
---|
96 | <p> |
---|
97 | We can also specify where the toolset should look for the library: |
---|
98 | |
---|
99 | </p> |
---|
100 | <pre class="programlisting"> |
---|
101 | lib pythonlib : : <name>python22 <search>/opt/lib ; |
---|
102 | </pre> |
---|
103 | <p> |
---|
104 | |
---|
105 | And, of course, target alternatives can be used in the usual way: |
---|
106 | |
---|
107 | </p> |
---|
108 | <pre class="programlisting"> |
---|
109 | lib pythonlib : : <name>python22 <variant>release ; |
---|
110 | lib pythonlib : : <name>python22_d <variant>debug ; |
---|
111 | </pre> |
---|
112 | <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 “Targets in site-config.jam”</a>. |
---|
113 | </p> |
---|
114 | </div> |
---|
115 | <table width="100%"><tr> |
---|
116 | <td align="left"></td> |
---|
117 | <td align="right"><small></small></td> |
---|
118 | </tr></table> |
---|
119 | <hr> |
---|
120 | <div class="spirit-nav"> |
---|
121 | <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> |
---|
122 | </div> |
---|
123 | </body> |
---|
124 | </html> |
---|