Setup
-
Create a new Zig project called
getty-learn
: -
Declare Getty as a dependency with
zig fetch
: -
Expose Getty as a module in
build.zig
:build.zig
pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const opts = .{ .target = target, .optimize = optimize }; const getty_mod = b.dependency("getty", opts).module("getty"); const exe = b.addExecutable(.{ .name = "my-project", .root_source_file = .{ .path = "src/main.zig" }, .target = target, .optimize = optimize, }); exe.root_module.addImport("getty", getty_mod); // ... }
-
Replace
src/main.zig
's content with the following code to ensure everything is correct: