Hi, my intention is to create binaries as releases for different targets, I depend on a library that is a wrapper for lmdb
, when I build not trying other target, I get no errors; Iβm on Linux Debian and have the distro lmdb-dev
package.
My zig.zon has the following
.dependencies = .{
.@"lmdb-zig" = .{
.url = "https://github.com/john-g4lt/lmdb-zig/archive/refs/tags/v0.1.0.tar.gz",
.hash = "1220a44f2880d150589664ee936da3b856674d732cbf02b4714a7282fa752facad97",
},
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz",
.hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b",
},
},
My build.zig
is including lmdb
:
const lib = b.addStaticLibrary(.{
.name = "tldrtranslate",
.root_source_file = b.path("src/tldr-base.zig"),
.target = target,
.optimize = optimize,
});
const lmdb_zig = b.dependency("lmdb-zig", .{ .target = target, .optimize = optimize });
lib.linkLibrary(lmdb_zig.artifact("lmdb-zig"));
b.installArtifact(lib);
const clap = b.dependency("clap", .{});
const exe = b.addExecutable(.{
.name = "tldrtranslate",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("lmdb-zig", lmdb_zig.module("lmdb-zig-mod"));
exe.root_module.addImport("clap", clap.module("clap"));
exe.linkLibrary(lmdb_zig.artifact("lmdb-zig"));
b.installArtifact(exe);
When I issue:
zig build --release=small -Dtarget=x86_64-native
My zig-out
looks like
$ tree zig-out/
zig-out/
βββ bin
β βββ tldrtranslate
βββ lib
βββ libtldrtranslate.a
βββ tldrtranslate.lib
zig version is 0.13.0
But when I try
zig build --release=small -Dtarget=x86_64-linux
I get
install
ββ install tldrtranslate
ββ zig build-exe tldrtranslate ReleaseSmall x86_64-linux 2 errors
/home/igor/.cache/zig/p/1220a44f2880d150589664ee936da3b856674d732cbf02b4714a7282fa752facad97/lmdb.zig:3:15: error: C import failed
pub const c = @cImport(@cInclude("lmdb.h"));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
Flags_Open: /home/igor/.cache/zig/p/1220a44f2880d150589664ee936da3b856674d732cbf02b4714a7282fa752facad97/lmdb.zig:73:15
remaining reference traces hidden; use '-freference-trace' to see all reference traces
/home/igor/playground/zig/tldrtranslate/.zig-cache/o/db7c6f3eac2005dc9bdd2050535739fd/cimport.h:1:10: error: 'lmdb.h' file not found
#include <lmdb.h>
^
error: the following command failed with 2 compilation errors:
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe /home/igor/playground/zig/tldrtranslate/.zig-cache/o/2f5c162fb8342cdcc282be84e2b526cf/liblmdb-zig.a -OReleaseSmall -target x86_64-linux -mcpu baseline -I /home/igor/playground/zig/tldrtranslate/.zig-cache/o/544790c738d38eb183fa637997b2e9c3 --dep lmdb-zig --dep clap -Mroot=/home/igor/playground/zig/tldrtranslate/src/main.zig -I /home/igor/.cache/zig/p/12209bfdbf43d479c2cac0ca2212853ab2136f1621f49461f62c7932a7819bc29110 -Mlmdb-zig=/home/igor/.cache/zig/p/1220a44f2880d150589664ee936da3b856674d732cbf02b4714a7282fa752facad97/lmdb.zig -Mclap=/home/igor/.cache/zig/p/122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b/clap.zig -lc --cache-dir /home/igor/playground/zig/tldrtranslate/.zig-cache --global-cache-dir /home/igor/.cache/zig --name tldrtranslate --listen=-
Build Summary: 4/7 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
ββ install tldrtranslate transitive failure
ββ zig build-exe tldrtranslate ReleaseSmall x86_64-linux 2 errors
error: the following build command failed with exit code 1:
/home/igor/playground/zig/tldrtranslate/.zig-cache/o/77f05256a4e3ee58b1da8cc9dd4c36bb/build /home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig /home/igor/playground/zig/tldrtranslate /home/igor/playground/zig/tldrtranslate/.zig-cache /home/igor/.cache/zig --seed 0xda6818d -Zfc4c5ea5d8e0cd72 --release=small -Dtarget=x86_64-linux
What am I missing?
And later one to automate the release, what is the preferred way to do so? Is it with additional steps in the build process? If this is the case, maybe is there a template for that purpose?