Compiling & Installing LevelDB on Linux
Update: Please also take a look at this followup article for an automatic compilation script that builds Ubuntu DEB packages!
Problem:
You want to compile and install LevelDB (including development headers) on your Linux computer. ./configure && make && make install
does not work so you don’t know how to do this.
or:
You have successfully compiled LevelDB, but make install doesn’t work (there is no official installation procedure yet) and you don’t know how to install it to your system
Solution
**Compilation:**Let’s start from scratch. I recommend using the bleeding-edge version in the git repository, but this method should also work for the downloadable archive
- Install git and snappy, for example on Ubuntu:
sudo apt-get install git-core libsnappy-dev
- Clone LevelDB into a directory of your choice:
git clone https://code.google.com/p/leveldb/
cd
into the directory*:*cd leveldb
make
You don’t neccessarily need snappy as LevelDB will work without it but you would need to recompile if you don’t install it before compiling.
Installation:
Excecute the following shell snippet as root from your LevelDB folder:
#!/bin/sh
cp --preserve=links libleveldb.* /usr/local/lib
cp -r include/leveldb /usr/local/include/
ldconfig
This installs LevelDB to /usr/local/lib
and /usr/local/include
in order to make it easier to uninstall/update it later.
This procedure might also work under other operating systems like Cygwin/MSYS-based environments, but I didn’t test this. Besides that I assume that LevelDB has been tested by Google on Linux servers only, so don’t assume it’s stable on other OSs without testing.
**Update 20 Jan 2013:**Added guide how to compile and what dependencies are needed