DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Berkeley DB Reference Guide:
Building Berkeley DB for Windows systems

PrevRefNext

Building for Windows

This page contains general instructions on building Berkeley DB for specific windows platforms using specific compilers. The Windows FAQ also contains helpful information.

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

Project FileDescription
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 the following platforms: Windows NT/2K/XP/2003, Windows 98/ME and 64-bit Windows XP/2003.

Building Berkeley DB for Windows NT/2K/XP/2003

Visual C++ .NET 2005

  1. Choose File -> Open -> Project/Solution.... In the build_win32, select Berkeley_DB and click Open.

  2. You will be prompted to convert the project files to current Visual C++ format. Select "Yes to All".

  3. Choose the project configuration from the drop-down menu on the tool bar (usually Debug or Release for Win32).

  4. To build, right-click on the build_all target and select Build.

Visual C++ .NET or Visual C++ .NET 2003

This is very similar to the building with Visual Studio 2005, but some menu options have been rearranged:

  1. Choose File -> Open Solution. Look in the build_win32 directory for compatible workspace files, select Berkeley_DB.dsw, and press Open.

  2. You will be prompted to convert the project files to current Visual C++ format. Select "Yes to All".

  3. Choose the project configuration from the drop-down menu on the .NET tool bar (Debug or Release).

  4. To build, right-click on build_all and select Build.

Visual C++ 6.0

  1. Choose File -> Open Workspace. Look in the build_win32 directory for Workspaces, select Berkeley_DB.dsw, and press Open.

  2. Choose the desired project configuration by going to Build -> Set Active Configuration and select the appropriate option to the build_all project (Debug or Release). Then click OK.

  3. To build, press F7.

Build results

The results of your build will be placed in a subdirectory of build_win32 named after the configuration you chose (for examples, build_win32\Release or build_win32\Debug).

When building your application during development, you should normally use compile options "Debug Multithreaded DLL" and link against build_win32\Debug\libdb44d.lib. You can also build using a release version of the Berkeley DB libraries and tools, which will be placed in build_win32\Release\libdb44.lib. When linking against the release build, you should compile your code with the "Release Multithreaded DLL" compile option. You will also need to add the build_win32 directory to the list of include directories of your application's project, or copy the Berkeley DB include files to another location.

Building Berkeley DB for Windows 98/ME

By default on Windows, Berkeley DB supports internationalized filenames by treating all directory paths and filenames passed to Berkeley DB methods as UTF-8 encoded strings. All paths are internally converted to wide character strings and passed to the wide character variants of Windows system calls.

This allows applications to create and open databases with names that cannot be represented with ASCII names while maintaining compatibility with applications that work purely with ASCII paths.

Windows 98 and ME do not support Unicode paths directly. To build for those versions of Windows, either follow the above instructions, choosing the "Debug ASCII" or "Release ASCII" build targets, or follow the instructions at Microsoft's web site.

The ASCII builds will also work on Windows NT/2K/XP and 2003, but will not translate paths to wide character strings.

Building Berkeley DB for 64-bit Windows

The following procedure can be used on either to build natively on a 64-bit system or to cross-compile from a 32-bit system.

x64 build with Visual Studio 2005

  1. Choose File -> Open -> Project/Solution.... In the build_win32, select Berkeley_DB and click Open.

  2. You will be prompted to convert the project files to current Visual C++ format. Select "Yes to All".

  3. Choose the project configuration from the drop-down menu on the tool bar ("Debug AMD64", "Release AMD64"). Change the CPU type from Win32 to x64.

  4. Right-click on the build_all target and select Build.

64-bit build with Visual Studio .NET 2003 or earlier

You will need latest Platform SDK from Microsoft, available from Microsoft's web site. You only need the "Core SDK" from there.

Once that is installed, you should have an entry in your Start Menu called Microsoft Platform SDK (date) -> Open Build Environment Window -> Windows Server 2003 64-bit Build Environment -> Set Win Svr 2003 x64 Build Env (Debug). Selecting that will open a command window with the environment set up for 64-bit Windows development targeting AMD64-compatible CPUs.

Depending on how your computer is configured, you may need to run the vcvars32.bat or script to set up the environment to build from the command line with Visual Studio.

Then, in the build_win32 directory in the Berkeley DB distribution, run this for Visual Studio .NET:

devenv Berkeley_DB.dsw
Choose "Yes To All" in the dialog box that appears, then close Visual Studio, then run:
devenv Berkeley_DB.sln /build "Debug AMD64" /project "build_all" /useenv
For Visual Studio 6, just run this instead:
msdev Berkeley_DB.dsw /make "build_all - Debug AMD64" /useenv
You should now have AMD64 binaries in the "Debug_AMD64" directory.

To build a release, open the "Retail" window instead of the "Debug" window, and change Debug to Release in the above commands. To build for Itanium, change AMD64 and x64 to IA64.

Building Berkeley DB with Cygwin

To build Berkeley DB with Cygwin, follow the instructions in Building for UNIX.

Building the C++ API

C++ support is built automatically on Windows.

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.

Building Java with Visual C++ .NET or above

  1. Set your include directories. Choose Tools -> Options -> Projects -> VC++ Directories. Under the "Show directories for" pull-down, select "Include files". Add the full pathnames for the d:\java\include and d:\java\include\win32 directories. Then click OK. These are the directories needed when including jni.h.

  2. Set the executable files directories. Choose Tools -> Options -> Projects -> VC++ Directories. Under the "Show directories for" pull-down, select "Executable files". Add the full pathname for the d:\java\bin directory, then click OK. This is the directory needed to find javac.

  3. Set the build type to Release or Debug in the drop-down on the .NET tool bar.

  4. To build, right-click on db_java and select Build. 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 or build_win32\Debug subdirectory of Berkeley DB.

Building Java with Visual C++ 6.0

  1. Set the include directories. Choose Tools -> Options -> Directories. Under the "Show directories for" pull-down, select "Include files". Add the full pathnames for the d:\java\include and d:\java\include\win32 directories. These are the directories needed when including jni.h.

  2. Set the executable files directories. Choose Tools -> Options -> Directories. Under the "Show directories for" pull-down, select "Executable files". Add the full pathname for the d:\java\bin directory. This is the directory needed to find javac.

  3. Go to Build -> Set Active Configuration and select either the Debug or Release version of the db_java project. Then press OK.

  4. To build, select Build -> Build libdb_java44.dll. 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 or build_win32\Debug subdirectory of Berkeley DB.

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 db.AccessExample

If you want to run Java code using a Debug build, substitute 'Debug' for 'Release' in the instructions above. Make sure you use the Debug JAR file with the Debug DLL and the Release JAR with the Release DLL.

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. These notes assume that Tcl is installed as d:\tcl, but you can change that if you want.

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 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.

Building Tcl with Visual C++ .NET or above

  1. Set the include directories. Choose Tools -> Options -> Projects -> VC++ Directories. Under the "Show directories for" pull-down, select "Include files". Add the full pathname for d:\tcl\include, then click OK. This is the directory that contains tcl.h.

  2. Set the library files directory. Choose Tools -> Options -> Projects -> VC++ Directories. Under the "Show directories for" pull-down, select "Library files". Add the full pathname for the d:\tcl\lib directory, then click OK. This is the directory needed to find tcl84g.lib (or whatever the library is named in your distribution).

  3. Set the build type to Release or Debug in the drop-down on the .NET tool bar.

  4. To build, right-click on db_tcl and select Build. This builds the Tcl support library for Berkeley DB, placing the result into build_win32\Debug\libdb_tcl44d.dll or build_win32\Release\libdb_tcl44.dll.

If you use a version different from Tcl 8.4.x you will need to change the name of the Tcl library used in the build (for example, tcl84g.lib) to the appropriate name. To do this, right click on db_tcl, go to Properties -> Linker -> Input -> Additional dependencies and change tcl84g.lib to match the Tcl version you are using.

Building Tcl with Visual C++ 6.0

  1. Set the include directories. Choose Tools -> Options -> Directories. Under the "Show directories for" pull-down, select "Include files". Add the full pathname for d:\tcl\include, then click OK. This is the directory that contains tcl.h.

  2. Set the library files directory. Choose Tools -> Options -> Directories. Under the "Show directories for" pull-down, select "Library files". Add the full pathname for the d:\tcl\lib directory, then click OK. This is the directory needed to find tcl84g.lib (or whatever the library is named in your distribution).

  3. Go to Build -> Set Active Configuration and select either the Debug or Release version of the db_tcl project. Then press OK.

  4. To build, select Build -> Build libdb_tcl44.dll. This builds the Tcl support library for Berkeley DB, placing the result into build_win32\Debug\libdb_tcl44d.dll or build_win32\Release\libdb_tcl44.dll.

If you use a version different from Tcl 8.4.x you will need to change the name of the Tcl library used in the build (for example, tcl84g.lib) to the appropriate name. To do this, choose Project -> Settings -> db_tcl and change the Tcl library listed in the Object/Library modules tcl84g.lib to match the Tcl version you are using.

Distributing DLLs

When distributing applications linked against the DLL (not static) version of the library, the DLL files you need will be found in the build_win32\Release subdirectory, or build_win32\Debug if you distribute a debug version. You may also need to redistribute DLL files needed for the compiler's runtime. For Visual C++ 6.0, these files are msvcrt.dll and msvcp60.dll if you built with a Release configuration, or msvcrtd.dll and msvcp60d.dll if you are using a Debug configuration. Generally, these runtime DLL files can be installed in the same directory that will contain your installed Berkeley DB DLLs. This directory may need to be added to your System PATH environment variable. Check your compiler's license and documentation for specifics on redistributing runtime DLLs.


PrevRefNext

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.