Skip to content

HOWTO:BuildLevelDBJNI

michaelcahill edited this page Sep 8, 2014 · 4 revisions

LevelDB JNI

Description

This page describes how to build the JNI layer for WiredTiger's LevelDB API based on this project:

http://github.com/fusesource/leveldbjni

Building

Prerequisites

Supported Platforms

The following worked for me on:

  • OS X Lion with X Code 4
  • CentOS 5.6 (32 and 64 bit)
  • Ubuntu 12.04 (32 and 64 bit)
  • apt-get install autoconf libtool snappy

Build Procedure

Then download the snappy, leveldb, and leveldbjni project source code:

git clone git://github.com/wiredtiger/wiredtiger.git -b develop
git clone git://github.com/fusesource/leveldbjni.git
export SNAPPY_HOME=/usr/lib64
export LEVELDBJNI_HOME=`cd leveldbjni; pwd`
export LEVELDB_HOME=$LEVELDBJNI_HOME/LOCAL_INSTALL
export WIREDTIGER_HOME=`cd wiredtiger; pwd`

Build WiredTiger to produce a static library.

cd ${WIREDTIGER_HOME}
./autogen.sh
./configure --disable-shared --with-pic --enable-leveldb --with-builtins=snappy --prefix=$LEVELDB_HOME
make install

Fix the WiredTiger install to match the tree leveldbjni expects

cd ${LEVELDB_HOME}
ln -s lib/wiredtiger/libleveldb.a .
ln -s wiredtiger/leveldb include

Now use maven to build the leveldbjni project.

cd ${LEVELDBJNI_HOME}
mvn clean install -P download -P ${platform} -fn

Expect some test failures -- see Caveats for details.

Replace ${platform} with one of the following platform identifiers (depending on the platform your building on):

  • osx
  • linux32
  • linux64
  • win32
  • win64

If your platform does not have the right auto-tools levels available just copy the leveldbjni-${version}-SNAPSHOT-native-src.zip artifact from a platform the does have the tools available then add the following argument to your maven build:

-Dnative-src-url=file:leveldbjni-${verision}-SNAPSHOT-native-src.zip

Build Results

  • leveldbjni/target/leveldbjni-${version}.jar : The java class file to the library.
  • leveldbjni/target/leveldbjni-${version}-native-src.zip : A GNU style source project which you can use to build the native library on other systems.
  • leveldbjni-${platform}/target/leveldbjni-${platform}-${version}.jar : A jar file containing the built native library using your currently platform.

Caveats

The following features of LevelDB are not yet supported (and cause several tests to fail):

  • custom comparators
  • statistics (vi DB::getProperty)
  • message logging