#+TITLE: RocksDB bindings for Zig #+DATE: 2024-04-27T11:27:04+0800 #+LASTMOD: 2025-09-21T19:58:16+0800 #+AUTHOR: Jiacai Liu [[https://img.shields.io/badge/zig%20version-0.15.1-blue.svg]] [[https://github.com/jiacai2050/zig-rocksdb/actions/workflows/CI.yml][https://github.com/jiacai2050/zig-rocksdb/actions/workflows/CI.yml/badge.svg]] [[https://github.com/facebook/rocksdb/][RocksDB]] binding for Zig. * Usage See [[file:examples/basic.zig]], [[file:examples/cf.zig]] for details. * Documentation #+begin_quote https://jiacai2050.github.io/zig-rocksdb #+end_quote * Installation #+begin_src bash zig fetch --save=rocksdb https://github.com/jiacai2050/zig-rocksdb/archive/${COMMIT}.tar.gz #+end_src Replace ~${COMMIT}~ with a real one, then in your =build.zig=, import the module like this: #+begin_src zig const dep_rocksdb = b.dependency("rocksdb", .{}); exe.root_module.addImport("rocksdb", dep_rocksdb.module("rocksdb")); exe.linkLibC(); #+end_src This library will link to a vendored [[https://github.com/facebook/rocksdb/releases/tag/v9.0.0][librocksdb(v9.0.0)]] by default, you can disable it and link to system-wide with this #+begin_src zig const dep_rocksdb = b.dependency("rocksdb", .{ .link_vendor = false }); exe.linkSystemLibrary("rocksdb"); exe.linkLibC(); #+end_src * Acknowledge Thanks to [[https://github.com/rust-rocksdb/rust-rocksdb][rust-rocksdb]], I benefit a lot from it when build this building library. * License [[file:LICENSE][MIT]]