INSTALL.md 3.9 KB
Newer Older
1 2
## Compilation

3 4 5 6
**Important**: If you plan to run RocksDB in production, don't compile using default 
`make` or `make all`. That will compile RocksDB in debug mode, which is much slower
than release mode.

7 8
RocksDB's library should be able to compile without any dependency installed,
although we recommend installing some compression libraries (see below).
9
We do depend on newer gcc/clang with C++11 support.
10 11

There are few options when compiling RocksDB:
I
Igor Canadi 已提交
12

13
* [recommended] `make static_lib` will compile librocksdb.a, RocksDB static library. Compiles static library in release mode.
I
Igor Canadi 已提交
14

15
* `make shared_lib` will compile librocksdb.so, RocksDB shared library. Compiles shared library in release mode.
16

17
* `make check` will compile and run all the unit tests. `make check` will compile RocksDB in debug mode.
18 19

* `make all` will compile our static library, and all our tools and unit tests. Our tools
20 21
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.
22

23
* By default the binary we produce is optimized for the platform you're compiling on
24
(-march=native or the equivalent). If you want to build a portable binary, add 'PORTABLE=1' before
25
your make commands, like this: `PORTABLE=1 make static_lib`
26

27 28 29
## Dependencies

* You can link RocksDB with following compression libraries:
I
Igor Canadi 已提交
30 31 32 33 34
  - [zlib](http://www.zlib.net/) - a library for data compression.
  - [bzip2](http://www.bzip.org/) - a library for data compression.
  - [snappy](https://code.google.com/p/snappy/) - a library for fast
      data compression.

35
* All our tools depend on:
A
Aaron Feldman 已提交
36
  - [gflags](https://gflags.github.io/gflags/) - a library that handles
37 38
      command line flags processing. You can compile rocksdb library even
      if you don't have gflags installed.
I
Igor Canadi 已提交
39 40 41

## Supported platforms

42
* **Linux - Ubuntu**
I
Igor Canadi 已提交
43
    * Upgrade your gcc to version at least 4.7 to get C++11 support.
44
    * Install gflags. First, try: `sudo apt-get install libgflags-dev`
45
      If this doesn't work and you're using Ubuntu, here's a nice tutorial:
I
Igor Canadi 已提交
46 47 48 49 50
      (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`.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
* **Linux - CentOS**
    * Upgrade your gcc to version at least 4.7 to get C++11 support:
      `yum install gcc47-c++`
    * Install gflags:

              wget https://gflags.googlecode.com/files/gflags-2.0-no-svn-files.tar.gz
              tar -xzvf gflags-2.0-no-svn-files.tar.gz
              cd gflags-2.0
              ./configure && make && sudo make install

    * Install snappy:

              wget https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz
              tar -xzvf snappy-1.1.1.tar.gz
              cd snappy-1.1.1
              ./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

I
Igor Canadi 已提交
78
* **OS X**:
K
Kai Liu 已提交
79
    * Install latest C++ compiler that supports C++ 11:
K
Kai Liu 已提交
80 81
        * Update XCode:  run `xcode-select --install` (or install it from XCode App's settting).
        * Install via [homebrew](http://brew.sh/).
K
Kai Liu 已提交
82
            * If you're first time developer in MacOS, you still need to run: `xcode-select --install` in your command line.
83
            * run `brew tap homebrew/versions; brew install gcc47 --use-llvm` to install gcc 4.7 (or higher).
84
    * run `brew install rocksdb`
I
Igor Canadi 已提交
85

I
Igor Canadi 已提交
86
* **iOS**:
I
Igor Canadi 已提交
87
  * 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`.
88 89

* **Windows**:
90
  * For building with MS Visual Studio 13 you will need Update 4 installed.
D
Dima 已提交
91
  * Read and follow the instructions at CMakeLists.txt