2014-05-08 01:51:30 +02:00
## Compilation
2017-03-17 19:39:00 +01:00
**Important**: If you plan to run RocksDB in production, don't compile using default
2015-10-08 23:11:32 +02:00
`make` or `make all` . That will compile RocksDB in debug mode, which is much slower
than release mode.
2014-05-08 01:51:30 +02:00
RocksDB's library should be able to compile without any dependency installed,
although we recommend installing some compression libraries (see below).
2014-12-15 11:29:41 +01:00
We do depend on newer gcc/clang with C++11 support.
2014-05-08 01:51:30 +02:00
There are few options when compiling RocksDB:
2013-11-18 20:44:17 +01:00
2015-10-08 23:11:32 +02:00
* [recommended] `make static_lib` will compile librocksdb.a, RocksDB static library. Compiles static library in release mode.
2013-11-18 20:44:17 +01:00
2015-10-08 23:11:32 +02:00
* `make shared_lib` will compile librocksdb.so, RocksDB shared library. Compiles shared library in release mode.
2014-05-08 01:51:30 +02:00
2015-10-08 23:11:32 +02:00
* `make check` will compile and run all the unit tests. `make check` will compile RocksDB in debug mode.
2014-05-08 01:51:30 +02:00
* `make all` will compile our static library, and all our tools and unit tests. Our tools
2015-10-08 23:11:32 +02:00
depend on gflags. You will need to have gflags installed to run `make all` . This will compile RocksDB in debug mode. Don't
use binaries compiled by `make all` in production.
2014-05-08 01:51:30 +02:00
2014-12-15 11:29:41 +01:00
* By default the binary we produce is optimized for the platform you're compiling on
2016-01-19 16:08:19 +01:00
(-march=native or the equivalent). If you want to build a portable binary, add 'PORTABLE=1' before
2017-03-17 19:39:00 +01:00
your make commands, like this: `PORTABLE=1 make static_lib` . If you want to build a binary that
makes use of SSE4, add 'USE_SSE=1' before your make commands, like this: `USE_SSE=1 make static_lib` .
2014-09-30 02:25:02 +02:00
2014-05-08 01:51:30 +02:00
## Dependencies
* You can link RocksDB with following compression libraries:
2013-11-18 20:44:17 +01:00
- [zlib ](http://www.zlib.net/ ) - a library for data compression.
- [bzip2 ](http://www.bzip.org/ ) - a library for data compression.
2017-02-13 07:53:42 +01:00
- [snappy ](http://google.github.io/snappy/ ) - a library for fast
2013-11-18 20:44:17 +01:00
data compression.
2017-02-13 07:53:42 +01:00
- [zstandard ](http://www.zstd.net ) - Fast real-time compression
algorithm.
2013-11-18 20:44:17 +01:00
2014-05-08 01:51:30 +02:00
* All our tools depend on:
2015-06-22 18:31:52 +02:00
- [gflags ](https://gflags.github.io/gflags/ ) - a library that handles
2014-05-08 01:51:30 +02:00
command line flags processing. You can compile rocksdb library even
if you don't have gflags installed.
2013-11-18 20:44:17 +01:00
## Supported platforms
2014-01-29 17:41:43 +01:00
* **Linux - Ubuntu**
2016-10-29 20:54:27 +02:00
* Upgrade your gcc to version at least 4.8 to get C++11 support.
2014-01-29 17:41:43 +01:00
* Install gflags. First, try: `sudo apt-get install libgflags-dev`
2013-12-02 15:48:23 +01:00
If this doesn't work and you're using Ubuntu, here's a nice tutorial:
2013-11-18 20:44:17 +01:00
(http://askubuntu.com/questions/312173/installing-gflags-12-04)
* Install snappy. This is usually as easy as:
`sudo apt-get install libsnappy-dev` .
* Install zlib. Try: `sudo apt-get install zlib1g-dev` .
* Install bzip2: `sudo apt-get install libbz2-dev` .
2017-02-13 07:53:42 +01:00
* Install zstandard: `sudo apt-get install libzstd-dev` .
* **Linux - CentOS / RHEL**
2016-10-29 20:54:27 +02:00
* Upgrade your gcc to version at least 4.8 to get C++11 support:
`yum install gcc48-c++`
2014-01-29 17:41:43 +01:00
* Install gflags:
2017-02-13 07:53:42 +01:00
git clone https://github.com/gflags/gflags.git
cd gflags
2017-04-03 20:58:00 +02:00
git checkout v2.0
2014-01-29 17:41:43 +01:00
./configure & & make & & sudo make install
2017-04-05 01:24:08 +02:00
**Notice** : Once installed, please add the include path for gflags to your CPATH env var and the
lib path to LIBRARY_PATH. If installed with default settings, the lib will be /usr/local/lib
and the include path will be /usr/local/include.
2014-01-29 17:41:43 +01:00
* Install snappy:
2017-02-13 07:53:42 +01:00
wget https://github.com/google/snappy/releases/download/1.1.4/snappy-1.1.4.tar.gz
tar -xzvf snappy-1.1.4.tar.gz
cd snappy-1.1.4
2014-01-29 17:41:43 +01:00
./configure & & make & & sudo make install
* Install zlib:
sudo yum install zlib
sudo yum install zlib-devel
* Install bzip2:
sudo yum install bzip2
sudo yum install bzip2-devel
2017-02-13 07:53:42 +01:00
* Install zstandard:
wget https://github.com/facebook/zstd/archive/v1.1.3.tar.gz
2017-04-03 20:58:00 +02:00
mv v1.1.3.tar.gz zstd-1.1.3.tar.gz
2017-02-13 07:53:42 +01:00
tar zxvf zstd-1.1.3.tar.gz
cd zstd-1.1.3
make & & sudo make install
2013-11-18 20:44:17 +01:00
* **OS X**:
2013-11-20 23:54:53 +01:00
* Install latest C++ compiler that supports C++ 11:
2013-11-20 23:55:33 +01:00
* Update XCode: run `xcode-select --install` (or install it from XCode App's settting).
* Install via [homebrew ](http://brew.sh/ ).
2013-11-20 23:54:53 +01:00
* If you're first time developer in MacOS, you still need to run: `xcode-select --install` in your command line.
2016-10-29 20:54:27 +02:00
* run `brew tap homebrew/versions; brew install gcc48 --use-llvm` to install gcc 4.8 (or higher).
2014-12-15 11:29:41 +01:00
* run `brew install rocksdb`
2013-11-18 20:44:17 +01:00
2014-04-04 22:11:44 +02:00
* **iOS**:
2014-10-01 20:15:42 +02:00
* Run: `TARGET_OS=IOS make static_lib` . When building the project which uses rocksdb iOS library, make sure to define two important pre-processing macros: `ROCKSDB_LITE` and `IOS_CROSS_COMPILE` .
2015-07-08 01:58:20 +02:00
* **Windows**:
2015-10-15 20:06:02 +02:00
* For building with MS Visual Studio 13 you will need Update 4 installed.
2015-09-04 04:46:09 +02:00
* Read and follow the instructions at CMakeLists.txt