###

Berkeley DB Reference Guide:
  Building Berkeley DB for Windows systems

# Building for Win32

The build_win32 directory in the Berkeley DB distribution contains project files for Microsoft Visual C++:

Project File | Description
--- | ---
Berkeley_DB.dsw | Visual C++ 6.0 workspace
*.dsp | Visual C++ 6.0 projects

These project files can be used to build Berkeley DB for any Win32 platform: Windows/XP, Windows/2000, Windows/NT, Windows/98 and Windows/95.

### Building Berkeley DB with Visual C++

Open the file Berkeley_DB.dsw. This workspace includes a number of subprojects needed to build Berkeley DB. To do this in Visual C++ .NET, choose Open Solution from the File menu. Then choose Compatible Workspace Files under Files of type. After you select Berkeley_DB.dsw, you will be prompted to upgrade the project files. Choose Yes to All.

First, you'll need to set the include directories. To do this, select Options... from the Tools pull-down menu. In Visual C++ 6.0, a tabbed dialog should appear. Choose the Directories tab in the dialog, and for the Platform, select Win32. In Visual C++ .NET, a different window appears. Choose Projects, then VC++ Directories.

In either case, choose Include files under Show directories for. You should then add two directories to the list of directories: the full pathname of the build_win32 subdirectory of Berkeley DB, followed by the full pathname of the dbinc subdirectory of Berkeley DB. Then click OK.

In Visual C++ 6.0, select Active Project Configuration under the Build pull-down menu. For a debug version of the libraries, tools, and examples, select build_all -- Win32 Debug. Results from this build are put into build_win32/Debug. For a release version, select build_all -- Win32 Release; results are put into build_win32/Release. For a debug version that has all tools and examples built with static libraries, select build_all -- Win32 Debug Static; results are put into build_win32/Debug_static. For a release version of the same, select build_all -- Win32 Release Static; results are put into build_win32/Release_static. Finally, to build, select Build build_all.exe under the Build pull-down menu.

In Visual C++ .NET, choose the configuration from the drop down list on the tool bar (Debug, Release, Debug Static or Release Static). Then, to build, right-click on build_all and choose Build.

When building your application, you should normally use compile options "debug multithreaded dll" and link against build_win32/Debug/libdb41d.lib. If you want to link against a static (non-DLL) version of the library, use the "debug multithreaded" compile options and link against build_win32/Debug_static/libdb41sd.lib. You can also build using a release version of the libraries and tools, which will be placed in build_win32/Release/libdb41.lib. The static version will be in build_win32/Release_static/libdb41s.lib.

Each release of Berkeley DB is built and tested with this procedure using Microsoft Visual C++ 6.0, Standard Version and Microsoft Visual C++ .NET, Standard Version.

### Building the C++ API

C++ support is built automatically on Win32.

### Building the Java API

Java support is not built automatically. The following instructions assume that you have installed the Sun Java Development Kit in d:/java. Of course, if you installed elsewhere or have different Java software, you will need to adjust the pathnames accordingly. First, use the previous instructions to open the Tools/Options window for adding include directories. In addition to the directories specified previously, add d:/java/include and d:/java/include/win32. These are the directories needed when including jni.h. Now, before clicking OK, choose Executable files under Show directories for. Add d:/java/bin. That directory is needed to find javac. Now select OK.

In Visual C++ 6.0, select Active Project Configuration under the Build pull-down menu. Choose db_java -- Win32 Release. To build, select Build libdb_java41.dll under the Build pull-down menu. This builds the Java support library for Berkeley DB and compiles all the java files, placing the resulting db.jar and dbexamples.jar files in the build_win32/Release subdirectory of Berkeley DB.

In Visual C++ .NET, set the build type to Release in the drop down list on the toolbar, then right-click on db_java and choose Build.

To run Java code, set your environment variable CLASSPATH to include the full pathname of these jar files, and your environment variable PATH to include the build_win32/Release subdirectory. On Windows, remember that files or directories in the CLASSPATH and PATH variables must be separated by semicolons (unlike UNIX). Then, try running the following command as a test:

>     java com.sleepycat.examples.AccessExample

If you want to run Java code using a Debug build, it is slightly more complicated. Make sure you build the Debug version of db_java instead of the Release version. Also make sure that your PATH contains build_win32/Debug. Then run the following (as one command):

>     java -dsleepycat.db.libname=libdb_java41d com.sleepycat.examples.AccessExample

### Building the Tcl API

Tcl support is not built automatically. See Loading Berkeley DB with Tcl for information on sites from which you can download Tcl and which Tcl versions are compatible with Berkeley DB.

The Tcl library must be built as the same build type as the Berkeley DB library (both Release or both Debug). We found that the binary release of Tcl can be used with the Release configuration of Berkeley DB, but you will need to need to build Tcl from sources for the Debug configuration. Before building Tcl, you will need to modify its makefile to make sure that you are building a debug version, including thread support. This is because the set of DLLs linked into the Tcl executable must match the corresponding set of DLLs used by Berkeley DB.

These notes assume that Tcl is installed as d:/tcl, but you can change that if you want. If you run using a version of Tcl different from the one currently being used by Sleepycat Software, you will need to change the name of the Tcl library used in the build (for example, tcl83d.lib) to the appropriate name. See Projects->Settings->Link in the db_tcl subproject.

Use the previous instructions for Visual C++ to open the Tools/Options window for adding include directories. In addition to the directories specified previously, add d:/tcl/include. This is the directory that contains tcl.h. Then, in that same window, choose Library Files under Show directories for. Add d:/tcl/lib (or whatever directory contains tcl83d.lib in your distribution) to the list. Now, select OK.

In Visual C++ 6.0, select Active Project Configuration under the Build pull-down menu. Choose db_tcl -- Win32 Release. To build, select Build libdb_tcl41.dll under the Build pull-down menu. This builds the Tcl support library for Berkeley DB, placing the result into build_win32/Release/libdb_tcl41.dll. Selecting an Active Configuration of db_tcl -- Win32 Debug will build a debug version, placing the result into build_win32/Debug/libdb_tcl41d.dll.

In Visual C++ .NET, choose the build type (Debug or Release) from the drop down list on the toolbar, then right-click on db_tcl and choose Build.

Copyright Sleepycat Software