Debian Codegraph @

docs/installation/build_unix_shlib.html

raw
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>Dynamic shared libraries</title>
7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB Installation and Build Guide" />
10 <link rel="up" href="build_unix.html" title="Chapter 7.  Building Berkeley DB for UNIX/POSIX" />
11 <link rel="prev" href="build_unix_install.html" title="Installing Berkeley DB" />
12 <link rel="next" href="build_unix_test.html" title="Running the test suite under UNIX" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Dynamic shared libraries</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="build_unix_install.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 7. 
26 Building Berkeley DB for UNIX/POSIX
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="build_unix_test.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="build_unix_shlib"></a>Dynamic shared libraries</h2>
38 </div>
39 </div>
40 </div>
41 <p><span class="bold"><strong>Warning</strong></span>: the following information is intended to be generic and
42 is likely to be correct for most UNIX systems. Unfortunately, dynamic
43 shared libraries are not standard between UNIX systems, so there may be
44 information here that is not correct for your system. If you have
45 problems, consult your compiler and linker manual pages, or your system
46 administrator.</p>
47 <p>The Berkeley DB dynamic shared libraries are created with the name
48 libdb-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so, where <span class="bold"><strong>major</strong></span> is
49 the major version number and <span class="bold"><strong>minor</strong></span> is the minor version number.
50 Other shared libraries are created if Java and Tcl support are enabled:
51 specifically, libdb_java-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so
52 and libdb_tcl-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so.</p>
53 <p>On most UNIX systems, when any shared library is created, the linker
54 stamps it with a "SONAME". In the case of Berkeley DB, the SONAME
55 is libdb-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so. It is important to
56 realize that applications linked against a shared library remember the
57 SONAMEs of the libraries they use and not the underlying names in the
58 filesystem.</p>
59 <p>When the Berkeley DB shared library is installed, links are
60 created in the install lib directory so that
61 libdb-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so,
62 libdb-<span class="bold"><strong>major</strong></span>.so, and libdb.so all refer to the
63 same library. This library will have an SONAME of
64 libdb-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so.</p>
65 <p>Any previous versions of the Berkeley DB libraries that are
66 present in the install directory (such as libdb-2.7.so or
67 libdb-2.so) are left unchanged. (Removing or moving old shared
68 libraries is one drastic way to identify applications that have been
69 linked against those vintage releases.)</p>
70 <p>Once you have installed the Berkeley DB libraries, unless they are
71 installed in a directory where the linker normally looks for shared
72 libraries, you will need to specify the installation directory as part
73 of compiling and linking against Berkeley DB. Consult your system
74 manuals or system administrator for ways to specify a shared library
75 directory when compiling and linking applications with the
76 Berkeley DB libraries. Many systems support environment variables
77 (for example, LD_LIBRARY_PATH or LD_RUN_PATH), or system configuration
78 files (for example, /etc/ld.so.conf) for this purpose.</p>
79 <p><span class="bold"><strong>Warning</strong></span>: some UNIX installations may have an already existing
80 <code class="filename">/usr/lib/libdb.so</code>, and this library may be an incompatible
81 version of Berkeley DB.</p>
82 <p>We recommend that applications link against libdb.so (for example,
83 using -ldb). Even though the linker uses the file named
84 libdb.so, the executable file for the application remembers the
85 library's SONAME (libdb-<span class="bold"><strong>major</strong></span>.<span class="bold"><strong>minor</strong></span>.so). This
86 has the effect of marking the applications with the versions they need
87 at link time. Because applications locate their needed SONAMEs when
88 they are executed, all previously linked applications will continue to
89 run using the library they were linked with, even when a new version of
90 Berkeley DB is installed and the file <code class="filename">libdb.so</code>
91 is replaced with a new version.</p>
92 <p>Applications that know they are using features specific to a particular
93 Berkeley DB release can be linked to that release. For example, an
94 application wanting to link to Berkeley DB major release "3" can link
95 using -ldb-3, and applications that know about a particular
96 minor release number can specify both major and minor release numbers;
97 for example, -ldb-3.5.</p>
98 <p>If you want to link with Berkeley DB before performing library
99 installation, the "make" command will have created a shared library
100 object in the <code class="filename">.libs</code> subdirectory of the build directory, such
101 as <code class="filename">build_unix/.libs/libdb-major.minor.so</code>. If you want
102 to link a file against this library, with, for example, a major number
103 of "3" and a minor number of "5", you should be able to do something
104 like the following:</p>
105 <pre class="programlisting">cc -L BUILD_DIRECTORY/.libs -o testprog testprog.o -ldb-3.5
106 env LD_LIBRARY_PATH="BUILD_DIRECTORY/.libs:$LD_LIBRARY_PATH" ./testprog</pre>
107 <p>where <span class="bold"><strong>BUILD_DIRECTORY</strong></span> is the full directory path to the directory
108 where you built Berkeley DB.</p>
109 <p>The libtool program (which is configured in the build directory) can be
110 used to set the shared library path and run a program. For example,
111 the following runs the gdb debugger on the db_dump utility after setting
112 the appropriate paths:</p>
113 <pre class="programlisting">libtool gdb db_dump</pre>
114 <p>Libtool may not know what to do with arbitrary commands (it is hardwired
115 to recognize "gdb" and some other commands). If it complains the mode
116 argument will usually resolve the problem:</p>
117 <pre class="programlisting">libtool --mode=execute my_debugger db_dump</pre>
118 <p>On most systems, using libtool in this way is exactly equivalent to
119 setting the LD_LIBRARY_PATH environment variable and then executing the
120 program. On other systems, using libtool has the virtue of knowing about
121 any other details on systems that don't behave in this typical way.</p>
122 </div>
123 <div class="navfooter">
124 <hr />
125 <table width="100%" summary="Navigation footer">
126 <tr>
127 <td width="40%" align="left"><a accesskey="p" href="build_unix_install.html">Prev</a> </td>
128 <td width="20%" align="center">
129 <a accesskey="u" href="build_unix.html">Up</a>
130 </td>
131 <td width="40%" align="right"> <a accesskey="n" href="build_unix_test.html">Next</a></td>
132 </tr>
133 <tr>
134 <td width="40%" align="left" valign="top">Installing Berkeley DB </td>
135 <td width="20%" align="center">
136 <a accesskey="h" href="index.html">Home</a>
137 </td>
138 <td width="40%" align="right" valign="top"> Running the test suite under UNIX</td>
139 </tr>
140 </table>
141 </div>
142 </body>
143 </html>