Skip to main content

Overview

This guide covers installing RocksDB on various platforms. RocksDB can be compiled from source or installed via package managers on supported platforms.
Important: If you plan to run RocksDB in production, don’t compile using default make or make all. These compile RocksDB in debug mode, which is much slower than release mode.

Quick Install

Requirements

RocksDB requires modern C++ compiler support:
  • GCC >= 11 (for C++20 support)
  • Clang >= 10 (for C++20 support)
  • MSVC 2017 or later (Windows)

Building from Source

Linux (Ubuntu/Debian)

1

Install Dependencies

Install required development tools and compression libraries:
Compression libraries are optional but highly recommended. RocksDB can compile without them, but you’ll have fewer compression options.
2

Clone the Repository

3

Build Static Library (Recommended)

Build the release version for production use:
This compiles librocksdb.a in release mode with optimizations enabled.
Performance: By default, the binary is optimized for the CPU you’re compiling on (-march=native). For a more portable binary, use PORTABLE=1 make static_lib.
4

Build Shared Library (Optional)

If you need a shared library:
This creates librocksdb.so.
5

Install (Optional)

Install system-wide:

Linux (CentOS/RHEL)

1

Install Dependencies

For gflags:
Add gflags to your environment:
2

Build RocksDB

macOS

1

Install Xcode Command Line Tools

2

Install via Homebrew (Easiest)

This installs RocksDB and all dependencies.
3

Or Build from Source

Windows

FreeBSD

1

Install via Ports (Easiest)

2

Or Build from Source

Install dependencies:
Build RocksDB:

OpenBSD

1

Install Dependencies

2

Build RocksDB

Build Options

Compilation Targets

Recommended for production
Compiles librocksdb.a static library in release mode with optimizations
Shared library
Compiles librocksdb.so shared library in release mode
Testing
Compiles and runs all unit tests in debug mode (slow, for development only)
Debug build
Compiles static library, tools, and tests in debug mode (not for production!)

Build Variables

Architecture Optimization: By default, RocksDB uses -march=native which creates a binary optimized for your CPU but may not work on other machines. Use PORTABLE=1 for wider compatibility.

Compression Libraries

RocksDB supports multiple compression algorithms:
Fast compression with reasonable ratio
Ubuntu/Debian
CentOS/RHEL
Best for: Low CPU overhead, good default choice
Extremely fast compression
Ubuntu/Debian
CentOS/RHEL
Best for: Maximum speed, minimal CPU usage
Best compression ratio with good speed
Ubuntu/Debian
CentOS/RHEL
Best for: Balance of speed and compression ratio (recommended)
Standard compression
Ubuntu/Debian
CentOS/RHEL
Best for: Wide compatibility
High compression ratio, slower
Ubuntu/Debian
CentOS/RHEL
Best for: Archival, cold storage

Verifying Installation

After installation, verify RocksDB works:
test.cc
Compile and run:

Platform-Specific Notes

iOS

When building projects using RocksDB iOS library, define the preprocessor macro: IOS_CROSS_COMPILE

AIX 6.1

Solaris Sparc

Troubleshooting

Error: error: #error This file requires compiler and library support for the ISO C++ 2020 standardSolution: Upgrade to GCC 11+ or Clang 10+
Ubuntu
Error: Build succeeds but compression options don’t workSolution: Install compression libraries before building RocksDB. If you’ve already built RocksDB, clean and rebuild:
Issue: RocksDB runs very slowlySolution: You likely built in debug mode. Rebuild in release mode:

Next Steps

Quick Start

Build your first RocksDB application

API Reference

Explore the complete API

Configuration

Learn about RocksDB options and tuning

Examples

See real-world code examples