|
Berkeley DB includes a dynamically loadable Tcl API. The Tcl API requires that Tcl/Tk 8.1 or later already be installed on your system. We recommend that you install later releases of Tcl/Tk than 8.1, if possible, especially on Windows platforms, as we found that we had to make local fixes to the 8.1 release in a few cases. You can download a copy of Tcl from the Ajuba Solutions corporate web site.
This document assumes that you have 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 Configuring Berkeley DB or Building for Win32 for more information.
Once enabled, the Berkeley DB shared library for Tcl is automatically installed as part of the standard installation process. However, if you wish to be able to dynamically load it as a Tcl package into your script there are several steps that must be performed:
For example:
# tclsh8.1 % lappend auto_path /usr/local/BerkeleyDB/lib % pkg_mkIndex /usr/local/BerkeleyDB/lib libdb_tcl-3.2.so libdb-3.2.so
Note that your Tcl and Berkeley DB version numbers may differ from the example, and so your tclsh and and library names may be different.
The Berkeley DB package may be loaded into the user's interactive Tcl script (or wish session) via the "load" command. For example:
load /usr/local/BerkeleyDB/lib/libdb_tcl-3.2.so
Note that your Berkeley DB version numbers may differ from the example, and so the library name may be different.
If you installed your library to run as a Tcl package, Tcl application scripts should use the "package" command to indicate to the Tcl interpreter that it needs the Berkeley DB package and where to find it. For example:
lappend auto_path "/usr/local/BerkeleyDB/lib" package require Db_tcl
No matter which way the library gets loaded, it creates a command named berkdb. All of the Berkeley DB functionality is accessed via this command and additional commands it creates on behalf of the application. A simple test to determine if everything is loaded and ready is to ask for the version:
berkdb version -string
This should return you the Berkeley DB version in a string format.