I am completely new to zig and system programming. I do not understand anything from the zig build system and I want to include glfw and xcb.zig in my project. I have been looking for documentations on zig build system and using git to load packages but i keep getting errors. My zig version is 0.13.0 as I installed it with arch linux package manager. Here is how I proceed.
I start with xcb.zig first. I run zig init
in an empty directory named test
. Then I add these two lines in my build.zig just after const exe = ...
definition:
const xcb = b.dependency("xcb.zig", .{});
exe.root_module.addImport("xcb.zig", xcb.module("xcb.zig"));
Then I use the terminal in project location (test directory) and run `zig fetch --save git+url.
This should import xcb.zig library to my project. To use it I only need to write
const xcb=@import("xcb.zig");
in my main.zig, right?
I run zig build
to test it and get some error (I assume I have to do the same process when dealing with glfw:
/home/mortimer/.cache/zig/p/122027b8acfde5ce6f48010182a97a514ae8db575986f0a6f59014e29ef1a775ab25/build.zig:143
:22: error: no field named 'path' in union 'Build.LazyPath'
.path = try std.fs.path.join(b.allocator, &.{ cachePath, header }),
^\~\~\~
/usr/lib/zig/std/Build.zig:2171:22: note: union declared here
pub const LazyPath = union(enum) {
^\~\~\~\~
referenced by:
runBuild__anon_16335: /usr/lib/zig/std/Build.zig:2117:37
dependencyInner__anon_15170: /usr/lib/zig/std/Build.zig:2097:29
remaining reference traces hidden; use '-freference-trace' to see all reference traces
/home/mortimer/.cache/zig/p/1220a0ccc00ff9ee2df9ae313345dd93af2a8876772f127e8bc5c90eca7bd2547c34/build.zig:49:
45: error: expected type 'Build.Step.Compile.HeaderInstallation', found pointer
libxau.installed_headers.append(&install_file.step) catch @panic("OOM");
^
/home/mortimer/.cache/zig/p/1220a0ccc00ff9ee2df9ae313345dd93af2a8876772f127e8bc5c90eca7bd2547c34/build.zig:49:
45: note: address-of operator always returns a pointer
/home/mortimer/.cache/zig/p/12201e606115ddfe830f1a585919bdebe27d2217114d05b03b617fc0f274218514d3/build.zig:4:6
9: error: no field named 'path' in union 'Build.LazyPath'
const clap_mod = b.addModule("clap", .{ .root_source_file = .{ .path = "clap.zig" } });
^\~\~\~
/usr/lib/zig/std/Build.zig:2171:22: note: union declared here
pub const LazyPath = union(enum) {
^\~\~\~\~
/home/mortimer/.cache/zig/p/122027b8acfde5ce6f48010182a97a514ae8db575986f0a6f59014e29ef1a775ab25/build.zig:13:
25: error: root struct of file 'std' has no member named 'ChildProcess'
stderr_behavior: std.ChildProcess.StdIo,
\~\~\~^\~\~\~\~\~\~\~\~\~\~\~\~
/usr/lib/zig/std/std.zig:1:1: note: struct declared here
pub const ArrayHashMap = array_hash_map.ArrayHashMap;
^\~\~