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