1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title> |
---|
5 | How to control the library order on Unix? |
---|
6 | </title> |
---|
7 | <link rel="stylesheet" href="../../boostbook.css" type="text/css"> |
---|
8 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
---|
9 | <style type="text/css"> |
---|
10 | body { background-image: url('http://docbook.sourceforge.net/release/images/draft.png'); |
---|
11 | background-repeat: no-repeat; |
---|
12 | background-position: top left; |
---|
13 | /* The following properties make the watermark "fixed" on the page. */ |
---|
14 | /* I think that's just a bit too distracting for the reader... */ |
---|
15 | /* background-attachment: fixed; */ |
---|
16 | /* background-position: center center; */ |
---|
17 | }</style> |
---|
18 | <link rel="start" href="../../index.html" title="The Boost C++ Libraries"> |
---|
19 | <link rel="up" href="../faq.html" title="Chapter 27. Frequently Asked Questions"> |
---|
20 | <link rel="prev" href="s03.html" title=" |
---|
21 | How to control properties order? |
---|
22 | "> |
---|
23 | <link rel="next" href="external.html" title="Can I get output of external program as a variable in a Jamfile? |
---|
24 | "> |
---|
25 | </head> |
---|
26 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
27 | <table cellpadding="2" width="100%"> |
---|
28 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../boost.png"></td> |
---|
29 | <td align="center"><a href="../../../../index.htm">Home</a></td> |
---|
30 | <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> |
---|
31 | <td align="center"><a href="../../../../people/people.htm">People</a></td> |
---|
32 | <td align="center"><a href="../../../../more/faq.htm">FAQ</a></td> |
---|
33 | <td align="center"><a href="../../../../more/index.htm">More</a></td> |
---|
34 | </table> |
---|
35 | <hr> |
---|
36 | <div class="spirit-nav"> |
---|
37 | <a accesskey="p" href="s03.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.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="external.html"><img src="../../images/next.png" alt="Next"></a> |
---|
38 | </div> |
---|
39 | <div class="section" lang="en"> |
---|
40 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
---|
41 | <a name="id2861760"></a> |
---|
42 | How to control the library order on Unix? |
---|
43 | </h2></div></div></div> |
---|
44 | <p>On the Unix-like operating systems, the order in which static |
---|
45 | libraries are specified when invoking the linker is important, because by |
---|
46 | default, the linker uses one pass though the libraries list. Passing the |
---|
47 | libraries in the incorrect order will lead to a link error. Further, this |
---|
48 | behaviour is often used to make one library override symbols from |
---|
49 | another. So, sometimes it's necessary to force specific order of |
---|
50 | libraries. |
---|
51 | </p> |
---|
52 | <p>Boost.Build tries to automatically compute the right order. The |
---|
53 | primary rule is that if library a "uses" library b, then library a will |
---|
54 | appear on the command line before library b. Library a is considered to |
---|
55 | use b is b is present either in the sources of a or in its |
---|
56 | requirements. To explicitly specify the use relationship one can use the |
---|
57 | <use> feature. For example, both of the following lines will cause |
---|
58 | a to appear before b on the command line: |
---|
59 | </p> |
---|
60 | <pre class="programlisting"> |
---|
61 | lib a : a.cpp b ; |
---|
62 | lib a : a.cpp : <use>b ; |
---|
63 | </pre> |
---|
64 | <p> |
---|
65 | The same approach works for searched libraries, too: |
---|
66 | </p> |
---|
67 | <pre class="programlisting"> |
---|
68 | lib z ; |
---|
69 | lib png : : <use>z ; |
---|
70 | exe viewer : viewer png z ; |
---|
71 | </pre> |
---|
72 | </div> |
---|
73 | <table width="100%"><tr> |
---|
74 | <td align="left"></td> |
---|
75 | <td align="right"><small></small></td> |
---|
76 | </tr></table> |
---|
77 | <hr> |
---|
78 | <div class="spirit-nav"> |
---|
79 | <a accesskey="p" href="s03.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.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="external.html"><img src="../../images/next.png" alt="Next"></a> |
---|
80 | </div> |
---|
81 | </body> |
---|
82 | </html> |
---|