Berkeley DB Reference Guide: Building for BREW
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++

### Berkeley DB Reference Guide: Building Berkeley DB for BREW |

### Building for BREW

This page has general instructions for building the Berkeley DB library and applets for the BREW platform.

### Building Berkeley DB for the BREW simulator

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

Project File | Description
--- | ---
bdb_brew.dsw | Visual C++ 6.0 workspace
bdb_brew.dsp | Visual C++ 6.0 project

The project file can be used to build the Berkeley DB library for the BREW platform. Both BREW SDK versions 2 and 3 are supported. By default, the build is for BREW SDK version 2.

The steps for building the Berkeley DB library for the BREW Simulator are as follows:

1. Install the BREW SDK and BREW SDK Tools.

2. To build for BREW SDK version 3, edit the Berkeley DB source distribution file build_brew/db_config.h file and remove the line "#define HAVE_BREW_SDK2". No changes are required to build for BREW SDK version 2.

3. Select File -> Open Workspace. Look in the build_brew directory for Workspaces, select bdb_brew.dsw, and select Open.

4. The BREW SDK creates an environment entry "BREWDIR" after the SDK installation. Confirm the entry exists, and if not, create an environment entry which points to the BREW SDK's root directory.

5. For the BREW platform, only the project "bdb_brew" is available. Set the bdb_brew project as the active project and select the appropriate option for the build_all project (Debug or Release). Then select OK.

6. To build, press F7.

The build results are placed in a subdirectory of build_brew named after the selected configuration (for example, build_brew\Release or build_brew\Debug).

When building the application during development, you should normally use compile options "Debug Multithreaded DLL" and link against build_brew\Debug\bdb_brew.lib. You can also build using a release version of the Berkeley DB libraries and tools, which will be placed in build_brew\Release\bdb_brew.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_brew directory to the list of include directories of your application's project, or copy the Berkeley DB include files to another location.

### Building a BREW applet with Berkeley DB library

Building a Berkeley DB application in the BREW environment is similar to building in a Windows environment. Ensure that db.h is in the build include path and bdb_brew.lib is in the build library path (alternatively, you can add project dependencies to the bdb_brew project).

BREW applets require a few minor additions:

1. The BDBApp structure must be extended -- the extended definition of BDBApp is found in the include file db.h.

2. Before any Berkeley DB operations are performed, the applet must call the "int brew_bdb_begin(void)" function. This function returns 0 on success, and non-zero on failure.

3. After the last Berkeley DB operation is performed, the applet must call the "void brew_bdb_end(void)" function. Note that the brew_bdb_end function cannot be called in the applet "cleanup" function. If that is a requirement, use the following code instead:

   >     BDBApp *pMe=(BDBApp *)po;
   >     if (pMe->db_global_values != NULL)
   >     	FREE(pMe->db_global_values);

### Building a BREW applet for the physical device

The binaries linked with the Berkeley DB library for the BREW simulator are not target files that can run on the physical device. In order to build for the physical device, an ARM compiler is needed: the recommended ARM compiler is ARM Developer Suite 1.2.

The steps for building a BREW applet for the physical device are as follows:

1. Set the target BREW Applet project as the active project.

2. Select "Generate ARM Make file" in the BREW tool bar for VC6, and a make file will be generated (if this step does not work, confirm your ADS was correctly installed).

3. The Berkeley DB library must then be manually added to this make file. See the build_brew\bdbread.mak file in the Berkeley DB distribution for an example.

4. Select Tools -> BREW Application 'Make' to build.

The target .mod file will be created in the build directory, and this is the file which should be uploaded to the physical device.

Copyright (c) 1996,2007 Oracle. All rights reserved.