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
|
<!--$Id: intro.so,v 11.22 2003/03/25 00:27:08 mjc Exp $-->
<!--Copyright 1997-2003 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Loading Berkeley DB with Tcl</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Tcl API</dl></h3></td>
<td align=right><a href="../perl/intro.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../tcl/using.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p>
<h3 align=center>Loading Berkeley DB with Tcl</h3>
<p>Berkeley DB includes a dynamically loadable Tcl API, which requires that
Tcl/Tk 8.4 or later already be installed on your system. You can
download a copy of Tcl from the <a href="http://dev.scriptics.com/">Tcl Developer Xchange</a> Web site.</p>
<p>This document assumes that you already configured Berkeley DB for Tcl
support, and you have built and installed everything where you want it
to be. If you have not done so, see
<a href="../../ref/build_unix/conf.html">Configuring Berkeley DB</a> or
<a href="../../ref/build_win/intro.html">Building for Win32</a> for more
information.</p>
<h3>Installing as a Tcl Package</h3>
<p>Once enabled, the Berkeley DB shared library for Tcl is automatically installed
as part of the standard installation process. However, if you want to be
able to dynamically load it as a Tcl package into your script, there are
several steps that must be performed:</p>
<ol>
<p><li>Run the Tcl shell in the install directory.
<li>Append this directory to your auto_path variable.
<li>Run the pkg_mkIndex proc, giving the name of the Berkeley DB Tcl library.
</ol>
<p>For example:</p>
<blockquote><pre># tclsh8.4
% lappend auto_path /usr/local/BerkeleyDB.4.2/lib
% pkg_mkIndex /usr/local/BerkeleyDB.4.2/lib libdb_tcl-4.2.so</pre></blockquote>
<p>Note that your Tcl and Berkeley DB version numbers may differ from the
example, and so your tclsh and library names may be different.</p>
<h3>Loading Berkeley DB with Tcl</h3>
<p>The Berkeley DB package may be loaded into the user's interactive Tcl script
(or wish session) via the <b>load</b> command. For example:</p>
<blockquote><pre>load /usr/local/BerkeleyDB.4.2/lib/libdb_tcl-4.2.so</pre></blockquote>
<p>Note that your Berkeley DB version numbers may differ from the example, and so
the library name may be different.</p>
<p>If you installed your library to run as a Tcl package, Tcl application
scripts should use the <b>package</b> command to indicate to the Tcl
interpreter that it needs the Berkeley DB package and where to find it. For
example:</p>
<blockquote><pre>lappend auto_path "/usr/local/BerkeleyDB.4.2/lib"
package require Db_tcl</pre></blockquote>
<p>No matter which way the library gets loaded, it creates a command named
<b>berkdb</b>. All the Berkeley DB functionality is accessed via this
command and additional commands it creates on behalf of the application.
A simple test to determine whether everything is loaded and ready is to
display the library version, as follows:</p>
<blockquote><pre>berkdb version -string</pre></blockquote>
<p>This should return you the Berkeley DB version in a string format.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../perl/intro.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../tcl/using.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1><a href="../../sleepycat/legal.html">Copyright (c) 1996-2003</a> <a href="http://www.sleepycat.com">Sleepycat Software, Inc.</a> - All rights reserved.</font>
</body>
</html>
|