~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/docs/ref/build_unix/shlib.html

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--$Id: shlib.so,v 10.13 2001/06/07 19:03:20 bostic Exp $-->
 
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
 
3
<!--All rights reserved.-->
 
4
<html>
 
5
<head>
 
6
<title>Berkeley DB Reference Guide: Dynamic shared libraries</title>
 
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
 
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
 
9
</head>
 
10
<body bgcolor=white>
 
11
<a name="2"><!--meow--></a>
 
12
<table width="100%"><tr valign=top>
 
13
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Building Berkeley DB for UNIX systems</dl></h3></td>
 
14
<td align=right><a href="../../ref/build_unix/install.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/build_unix/test.html"><img src="../../images/next.gif" alt="Next"></a>
 
15
</td></tr></table>
 
16
<p>
 
17
<h1 align=center>Dynamic shared libraries</h1>
 
18
<p><b>Warning</b>: the following information is intended to be generic and
 
19
is likely to be correct for most UNIX systems.  Unfortunately, dynamic
 
20
shared libraries are not standard between UNIX systems, so there may be
 
21
information here that is not correct for your system.  If you have
 
22
problems, consult your compiler and linker manual pages, or your system
 
23
administrator.
 
24
<p>The Berkeley DB dynamic shared libraries are created with the name
 
25
libdb-<b>major</b>.<b>minor</b>.so, where <b>major</b> is the major
 
26
version number and <b>minor</b> is the minor version number.  Other
 
27
shared libraries are created if Java and Tcl support are enabled --
 
28
specifically, libdb_java-<b>major</b>.<b>minor</b>.so and
 
29
libdb_tcl-<b>major</b>.<b>minor</b>.so.
 
30
<p>On most UNIX systems, when any shared library is created, the linker
 
31
stamps it with a "SONAME".  In the case of Berkeley DB, the SONAME is
 
32
libdb-<b>major</b>.<b>minor</b>.so.  It is important to realize that
 
33
applications linked against a shared library remember the SONAMEs of the
 
34
libraries they use and not the underlying names in the filesystem.
 
35
<p>When the Berkeley DB shared library is installed, links are created in the
 
36
install lib directory so that libdb-<b>major</b>.<b>minor</b>.so,
 
37
libdb-<b>major</b>.so, and libdb.so all refer to the same library.  This
 
38
library will have an SONAME of libdb-<b>major</b>.<b>minor</b>.so.
 
39
<p>Any previous versions of the Berkeley DB libraries that are present in the
 
40
install directory (such as libdb-2.7.so or libdb-2.so) are left unchanged.
 
41
(Removing or moving old shared libraries is one drastic way to identify
 
42
applications that have been linked against those vintage releases.)
 
43
<p>Once you have installed the Berkeley DB libraries, unless they are installed
 
44
in a directory where the linker normally looks for shared libraries,
 
45
you will need to specify the installation directory as part of compiling
 
46
and linking against Berkeley DB.  Consult your system manuals or system
 
47
administrator for ways to specify a shared library directory when
 
48
compiling and linking applications with the Berkeley DB libraries.  Many
 
49
systems support environment variables (for example, LD_LIBRARY_PATH or
 
50
LD_RUN_PATH), or system configuration files (for example, /etc/ld.so.conf)
 
51
for this purpose.
 
52
<p><b>Warning</b>: some UNIX installations may have an already existing
 
53
<b>/usr/lib/libdb.so</b>, and this library may be an incompatible
 
54
version of Berkeley DB.
 
55
<p>We recommend that applications link against libdb.so (for example, using
 
56
-ldb).  Even though the linker uses the file named libdb.so, the
 
57
executable file for the application remembers the library's SONAME
 
58
(libdb-<b>major</b>.<b>minor</b>.so).  This has the effect of
 
59
marking the applications with the versions they need at link time.
 
60
Because applications locate their needed SONAMEs when they are executed,
 
61
all previously linked applications will continue to run using the
 
62
library they were linked with, even when a new version of Berkeley DB is
 
63
installed and the file <b>libdb.so</b> is replaced with a new
 
64
version.
 
65
<p>Applications that know they are using features specific to a particular
 
66
Berkeley DB release can be linked to that release.  For example, an application
 
67
wanting to link to Berkeley DB major release "3" can link using -ldb-3, and
 
68
applications that know about a particular minor release number can specify
 
69
both major and minor release numbers; for example, -ldb-3.5.
 
70
<p>If you want to link with Berkeley DB before performing library installation,
 
71
the "make" command will have created a shared library object in the
 
72
<b>.libs</b> subdirectory of the build directory, such as
 
73
<b>build_unix/.libs/libdb-major.minor.so</b>.  If you want to link a
 
74
file against this library, with, for example, a major number of "3" and
 
75
a minor number of "5", you should be able to do something like the
 
76
following:
 
77
<p><blockquote><pre>cc -L BUILD_DIRECTORY/.libs -o testprog testprog.o -ldb-3.5
 
78
env LD_LIBRARY_PATH="BUILD_DIRECTORY/.libs:$LD_LIBRARY_PATH" ./testprog</pre></blockquote>
 
79
<p>where <b>BUILD_DIRECTORY</b> is the full directory path to the directory
 
80
where you built Berkeley DB.
 
81
<p>The libtool program (which is configured in the build directory) can be
 
82
used to set the shared library path and run a program.  For example,
 
83
the following runs the gdb debugger on the db_dump utility after setting
 
84
the appropriate paths:
 
85
<p><blockquote><pre>libtool gdb db_dump</pre></blockquote>
 
86
<p>Libtool may not know what to do with arbitrary commands (it is hardwired
 
87
to recognize "gdb" and some other commands).  If it complains the mode
 
88
argument will usually resolve the problem:
 
89
<p><blockquote><pre>libtool --mode=execute my_debugger db_dump</pre></blockquote>
 
90
<p>On most systems, using libtool in this way is exactly equivalent to
 
91
setting the LD_LIBRARY_PATH environment variable and then executing the
 
92
program.  On other systems, using libtool has the virtue of knowing about
 
93
any other details on systems that don't behave in this typical way.
 
94
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/build_unix/install.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/build_unix/test.html"><img src="../../images/next.gif" alt="Next"></a>
 
95
</td></tr></table>
 
96
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
 
97
</body>
 
98
</html>