Chapter 7.  Building Berkeley DB for UNIX/POSIX

Table of Contents

Building for UNIX/POSIX
Building the Berkeley DB SQL Interface
Configuring Berkeley DB
Configuring the SQL Interface
Changing Compile Options
Enabling Extensions
Building the JDBC Driver
Using the JDBC Driver
Building the ODBC Driver
Building the BFILE extension
Building a small memory footprint library
Changing compile or load options
Cross-Compiling on Unix
Installing Berkeley DB
Dynamic shared libraries
Running the test suite under UNIX
Building SQL Test Suite on Unix
Architecture independent FAQ
Apple iOS (iPhone OS)
Mac OS X

Building for UNIX/POSIX

The Berkeley DB distribution builds up to four separate libraries: the base C API Berkeley DB library and the optional C++, Java, and Tcl API libraries. For portability reasons, each library is standalone and contains the full Berkeley DB support necessary to build applications; that is, the C++ API Berkeley DB library does not require any other Berkeley DB libraries to build and run C++ applications.

Building for Linux, Apple iOS (known as iPhone OS previously), Mac OS X or the QNX Neutrino release is the same as building for a conventional UNIX platform.

The Berkeley DB distribution uses the Free Software Foundation's autoconf and libtool tools to build on UNIX platforms. In general, the standard configuration and installation options for these tools apply to the Berkeley DB distribution.

To perform a standard UNIX build of Berkeley DB, change to the build_unix directory and then enter the following two commands:


This will build the Berkeley DB library.

To install the Berkeley DB library, enter the following command:

make install

To rebuild Berkeley DB, enter:

make clean

If you change your mind about how Berkeley DB is to be configured, you must start from scratch by entering the following command:

make realclean

To uninstall Berkeley DB, enter:

make uninstall

To build multiple UNIX versions of Berkeley DB in the same source tree, create a new directory at the same level as the build_unix directory, and then configure and build in that directory as described previously.

Building the Berkeley DB SQL Interface

To perform a standard UNIX build of the Berkeley DB SQL interface, go to the build_unix directory and then enter the following two commands:

../dist/configure --enable-sql

This creates a library, libdb_sql, and a command line tool, dbsql. You can create and manipulate SQL databases using the dbsql shell.

You can optionally provide the --enable-sql_compat argument to the configure script. In addition to creating libdb_sql and dbsql this causes a thin wrapper library called libsqlite3 and a command line tool called sqlite3 to be built. This library can be used as a drop-in replacement for SQLite. The sqlite3 command line tool is identical to the dbsql executable but is named so that existing scripts for SQLite can easily work with Berkeley DB.

../dist/configure --enable-sql_compat

There are several arguments you can specify when configuring the Berkeley DB SQL Interface. See Configuring the SQL Interface for more information.