Lmdb using the Zig build system
First, update your build.zig.zon
:
# Initialize a `zig build` project if you haven't already
zig init
# Support for `lmdb` starts with v0.9.31 and future releases
zig fetch --save https://github.com/allyourcodebase/lmdb/archive/refs/tags/0.9.31+1.tar.gz
# For latest main commit
zig fetch --save https://github.com/allyourcodebase/lmdb/archive/refs/heads/main.tar.gz
Import lmdb
dependency into build build.zig
as follows:
const lmdb_dep = b.dependency("lmdb", .{
.target = target,
.optimize = optimize,
.lto = true,
});
Using lmdb
artifacts and module in your project
const exe = b.addExecutable(.{
.name = exe_name,
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = strip,
});
exe.want_lto = lto;
const liblmdb = lmdb_dep.artifact("lmdb");
const lmdb_module = lmdb_dep.module("lmdb");
exe.root_module.addImport("mdb", lmdb_module);
exe.linkLibrary(liblmdb);
- Zig 0.14.0-dev
- Zig 0.13.0