]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | ## Compilation |
2 | ||
3 | **Important**: If you plan to run RocksDB in production, don't compile using default | |
4 | `make` or `make all`. That will compile RocksDB in debug mode, which is much slower | |
5 | than release mode. | |
6 | ||
7 | RocksDB's library should be able to compile without any dependency installed, | |
8 | although we recommend installing some compression libraries (see below). | |
1e59de90 | 9 | We do depend on newer gcc/clang with C++17 support (GCC >= 7, Clang >= 5). |
7c673cae FG |
10 | |
11 | There are few options when compiling RocksDB: | |
12 | ||
13 | * [recommended] `make static_lib` will compile librocksdb.a, RocksDB static library. Compiles static library in release mode. | |
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 | depend on gflags. You will need to have gflags installed to run `make all`. This will compile RocksDB in debug mode. Don't | |
21 | 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 | |
11fdf7f2 TL |
24 | (`-march=native` or the equivalent). SSE4.2 will thus be enabled automatically if your |
25 | CPU supports it. To print a warning if your CPU does not support SSE4.2, build with | |
26 | `USE_SSE=1 make static_lib` or, if using CMake, `cmake -DFORCE_SSE42=ON`. If you want | |
27 | to build a portable binary, add `PORTABLE=1` before your make commands, like this: | |
28 | `PORTABLE=1 make static_lib`. | |
7c673cae FG |
29 | |
30 | ## Dependencies | |
31 | ||
32 | * You can link RocksDB with following compression libraries: | |
33 | - [zlib](http://www.zlib.net/) - a library for data compression. | |
34 | - [bzip2](http://www.bzip.org/) - a library for data compression. | |
11fdf7f2 | 35 | - [lz4](https://github.com/lz4/lz4) - a library for extremely fast data compression. |
7c673cae FG |
36 | - [snappy](http://google.github.io/snappy/) - a library for fast |
37 | data compression. | |
38 | - [zstandard](http://www.zstd.net) - Fast real-time compression | |
39 | algorithm. | |
40 | ||
41 | * All our tools depend on: | |
42 | - [gflags](https://gflags.github.io/gflags/) - a library that handles | |
43 | command line flags processing. You can compile rocksdb library even | |
44 | if you don't have gflags installed. | |
45 | ||
1e59de90 TL |
46 | * `make check` will also check code formatting, which requires [clang-format](https://clang.llvm.org/docs/ClangFormat.html) |
47 | ||
494da23a TL |
48 | * If you wish to build the RocksJava static target, then cmake is required for building Snappy. |
49 | ||
1e59de90 TL |
50 | * If you wish to run microbench (e.g, `make microbench`, `make ribbon_bench` or `cmake -DWITH_BENCHMARK=1`), Google benchmark >= 1.6.0 is needed. |
51 | ||
7c673cae FG |
52 | ## Supported platforms |
53 | ||
54 | * **Linux - Ubuntu** | |
1e59de90 | 55 | * Upgrade your gcc to version at least 7 to get C++17 support. |
7c673cae FG |
56 | * Install gflags. First, try: `sudo apt-get install libgflags-dev` |
57 | If this doesn't work and you're using Ubuntu, here's a nice tutorial: | |
58 | (http://askubuntu.com/questions/312173/installing-gflags-12-04) | |
59 | * Install snappy. This is usually as easy as: | |
60 | `sudo apt-get install libsnappy-dev`. | |
61 | * Install zlib. Try: `sudo apt-get install zlib1g-dev`. | |
62 | * Install bzip2: `sudo apt-get install libbz2-dev`. | |
11fdf7f2 | 63 | * Install lz4: `sudo apt-get install liblz4-dev`. |
7c673cae FG |
64 | * Install zstandard: `sudo apt-get install libzstd-dev`. |
65 | ||
66 | * **Linux - CentOS / RHEL** | |
1e59de90 | 67 | * Upgrade your gcc to version at least 7 to get C++17 support |
7c673cae FG |
68 | * Install gflags: |
69 | ||
70 | git clone https://github.com/gflags/gflags.git | |
71 | cd gflags | |
72 | git checkout v2.0 | |
73 | ./configure && make && sudo make install | |
74 | ||
11fdf7f2 TL |
75 | **Notice**: Once installed, please add the include path for gflags to your `CPATH` environment variable and the |
76 | lib path to `LIBRARY_PATH`. If installed with default settings, the include path will be `/usr/local/include` | |
77 | and the lib path will be `/usr/local/lib`. | |
7c673cae FG |
78 | |
79 | * Install snappy: | |
80 | ||
11fdf7f2 | 81 | sudo yum install snappy snappy-devel |
7c673cae FG |
82 | |
83 | * Install zlib: | |
84 | ||
11fdf7f2 | 85 | sudo yum install zlib zlib-devel |
7c673cae FG |
86 | |
87 | * Install bzip2: | |
88 | ||
11fdf7f2 TL |
89 | sudo yum install bzip2 bzip2-devel |
90 | ||
91 | * Install lz4: | |
92 | ||
93 | sudo yum install lz4-devel | |
94 | ||
95 | * Install ASAN (optional for debugging): | |
96 | ||
97 | sudo yum install libasan | |
7c673cae FG |
98 | |
99 | * Install zstandard: | |
1e59de90 TL |
100 | * With [EPEL](https://fedoraproject.org/wiki/EPEL): |
101 | ||
102 | sudo yum install libzstd-devel | |
103 | ||
104 | * With CentOS 8: | |
105 | ||
106 | sudo dnf install libzstd-devel | |
7c673cae | 107 | |
1e59de90 TL |
108 | * From source: |
109 | ||
110 | wget https://github.com/facebook/zstd/archive/v1.1.3.tar.gz | |
111 | mv v1.1.3.tar.gz zstd-1.1.3.tar.gz | |
112 | tar zxvf zstd-1.1.3.tar.gz | |
113 | cd zstd-1.1.3 | |
114 | make && sudo make install | |
7c673cae FG |
115 | |
116 | * **OS X**: | |
1e59de90 | 117 | * Install latest C++ compiler that supports C++ 17: |
7c673cae FG |
118 | * Update XCode: run `xcode-select --install` (or install it from XCode App's settting). |
119 | * Install via [homebrew](http://brew.sh/). | |
120 | * If you're first time developer in MacOS, you still need to run: `xcode-select --install` in your command line. | |
1e59de90 | 121 | * run `brew tap homebrew/versions; brew install gcc7 --use-llvm` to install gcc 7 (or higher). |
7c673cae FG |
122 | * run `brew install rocksdb` |
123 | ||
11fdf7f2 TL |
124 | * **FreeBSD** (11.01): |
125 | ||
126 | * You can either install RocksDB from the Ports system using `cd /usr/ports/databases/rocksdb && make install`, or you can follow the details below to install dependencies and compile from source code: | |
127 | ||
128 | * Install the dependencies for RocksDB: | |
129 | ||
130 | export BATCH=YES | |
131 | cd /usr/ports/devel/gmake && make install | |
132 | cd /usr/ports/devel/gflags && make install | |
133 | ||
134 | cd /usr/ports/archivers/snappy && make install | |
135 | cd /usr/ports/archivers/bzip2 && make install | |
136 | cd /usr/ports/archivers/liblz4 && make install | |
137 | cd /usr/ports/archivesrs/zstd && make install | |
138 | ||
139 | cd /usr/ports/devel/git && make install | |
140 | ||
141 | ||
142 | * Install the dependencies for RocksJava (optional): | |
143 | ||
144 | export BATCH=yes | |
145 | cd /usr/ports/java/openjdk7 && make install | |
146 | ||
147 | * Build RocksDB from source: | |
148 | cd ~ | |
149 | git clone https://github.com/facebook/rocksdb.git | |
150 | cd rocksdb | |
151 | gmake static_lib | |
152 | ||
153 | * Build RocksJava from source (optional): | |
154 | cd rocksdb | |
155 | export JAVA_HOME=/usr/local/openjdk7 | |
156 | gmake rocksdbjava | |
157 | ||
158 | * **OpenBSD** (6.3/-current): | |
159 | ||
160 | * As RocksDB is not available in the ports yet you have to build it on your own: | |
161 | ||
162 | * Install the dependencies for RocksDB: | |
163 | ||
1e59de90 | 164 | pkg_add gmake gflags snappy bzip2 lz4 zstd git jdk bash findutils gnuwatch |
11fdf7f2 TL |
165 | |
166 | * Build RocksDB from source: | |
167 | ||
168 | cd ~ | |
169 | git clone https://github.com/facebook/rocksdb.git | |
170 | cd rocksdb | |
171 | gmake static_lib | |
172 | ||
173 | * Build RocksJava from source (optional): | |
174 | ||
175 | cd rocksdb | |
176 | export JAVA_HOME=/usr/local/jdk-1.8.0 | |
177 | export PATH=$PATH:/usr/local/jdk-1.8.0/bin | |
178 | gmake rocksdbjava | |
179 | ||
7c673cae FG |
180 | * **iOS**: |
181 | * 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`. | |
182 | ||
1e59de90 | 183 | * **Windows** (Visual Studio 2017 to up): |
7c673cae | 184 | * Read and follow the instructions at CMakeLists.txt |
1e59de90 | 185 | * Or install via [vcpkg](https://github.com/microsoft/vcpkg) |
11fdf7f2 | 186 | * run `vcpkg install rocksdb:x64-windows` |
7c673cae FG |
187 | |
188 | * **AIX 6.1** | |
189 | * Install AIX Toolbox rpms with gcc | |
190 | * Use these environment variables: | |
1e59de90 | 191 | |
7c673cae FG |
192 | export PORTABLE=1 |
193 | export CC=gcc | |
194 | export AR="ar -X64" | |
195 | export EXTRA_ARFLAGS=-X64 | |
196 | export EXTRA_CFLAGS=-maix64 | |
197 | export EXTRA_CXXFLAGS=-maix64 | |
198 | export PLATFORM_LDFLAGS="-static-libstdc++ -static-libgcc" | |
199 | export LIBPATH=/opt/freeware/lib | |
200 | export JAVA_HOME=/usr/java8_64 | |
201 | export PATH=/opt/freeware/bin:$PATH | |
1e59de90 | 202 | |
7c673cae | 203 | * **Solaris Sparc** |
1e59de90 | 204 | * Install GCC 7 and higher. |
7c673cae FG |
205 | * Use these environment variables: |
206 | ||
207 | export CC=gcc | |
208 | export EXTRA_CFLAGS=-m64 | |
209 | export EXTRA_CXXFLAGS=-m64 | |
210 | export EXTRA_LDFLAGS=-m64 | |
211 | export PORTABLE=1 | |
212 | export PLATFORM_LDFLAGS="-static-libstdc++ -static-libgcc" |