#LevelDB Component Wrapper
##What is it? This wraps the LevelDB database http://code.google.com/p/leveldb/ into a cross compiler component. This makes it easier to incorporate it into your program, especially on Windows. You do not need to worry about compilers or standard library versions being compatible with the compiler/standard library used to build the component.
##Why is this useful? This saves you from having to build LevelDB. This is mostly useful on Windows, where it can be a major pain to build LevelDB. See http://ayende.com/blog/161409/leveldb-windows-it-aint-a-love-story.
##What does this depend on? This depends on cppcomponents found at https://github.com/jbandela/cppcomponents. The cppcomponents library is a header only library that works on Windows and Linux and uses C++11 to make it easy to integrate code written that is written using different compilers or uses different standard libraries. For example on Windows, you can write code in g++ and easily call it from Visual C++. On linux you can write code in clang with libc++ and call it from g++.
##Will it work with my compiler?
cppcomponents which this library uses requires excellent C++11 support especially for variadic templates. This code has been tested with
Microsoft Visual Studio 2013 Preview, Mingw g++ 4.8.1 on Windows and g++ 4.7.2 and clang++ 3.4 with libc++ on Linux. Make sure to include
-std=c++11
with g++ and clang++
##How do I build code that uses this library?
-
Make sure you have
cppcomponents
in your header search path. You can download from https://github.com/jbandela/cppcomponents- You can use the
-I /path_to_cppcomponents
flag - If using a Visual C++ project add that to the Visual C++ Include files directories
- You can use the
-
Include
leveldb_interfaces.h
in your.cpp
file -
On Windows, that is all you need
-
On Linux, you need to add
-ldl
to your compiler command, otherwise you will getdlopen symbol not found
errors -
Copy either the
leveldb_cc_dll.dll
(for Windows) orleveldb_cc_dll.so
(for Linux) to the same directory as the executable file. You can find prebuilt binaries for Win32 and Linux_x64 in the Releases https://github.com/jbandela/leveldb_cross_compiler/releases inbinaries.zip
orbinaries.tar.gz
That's it, no complicated build steps, no copying different files for different compilers!
##How do I use this library?
Take a look at example.cpp
for a simple example
##How do I rebuild the .dll or .so file?
###On Windows
####Prerequisites
- Msys
- Mingw - I got mine from http://www.nuwen.net
####Steps
- Get LevelDB from https://github.com/ripple/leveldb
- Open msys and navigate to where you have the directory
- Add the path to ming binaries to the end of the
PATH
variable. For exampleset PATH=$PATH:/c/Mingw/bin/
export TARGET_OS=NATIVE_WINDOWS
make
- Download leveldb_cross_compiler from https://github.com/jbandela/leveldb_cross_compiler
C:\Users\jrb\Source\Repos\leveldb_cross_compiler>g++ leveldb_cc_dll.cpp -O2 -shared -o leveldb_cc_dll.dll ..\leveldb\libleveldb.a -I ..\leveldb\include -I cppcomponents -lshlwapi -std=c++11
replacing the paths tolibleveldb.a
andleveldb\include
andcppcomponents
as necessary
###On Linux
- Download LevelDB
- Go to the directory where you downloaded LevelDB
- Edit the
Makefile
and add-fPIC
to the end of theOPT ?=
make
- Download
cppcomponents
- Downlaod
leveldb_cross_compiler
- Go the leveldb_cross_compiler directory
g++ -shared -o leveldb_cc_dll.so leveldb_cc_dll.cpp ../leveldb-1.12.0/libleveldb.a -lpthread -I ../leveldb-1.12.0/include/ -I cppcomponents -std=c++11 -fPIC -O2
replacing the paths tolibleveldb.a
andleveldb\include
andcppcomponents
as necessary
##License
The interface files and implementation and example are distributed under
Copyright John R. Bandela 2013.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
The LevelDB files are
Copyright (c) 2011 The LevelDB Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. See the AUTHORS file for names of contributors.