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