How to import from the .zon file

The error is because the module has not been exposed. One possible solution is that adding following lines in the capy’s build.zig file.

    const mod = b.addModule("capy", .{
        .source_file = .{ .path = "src/main.zig" },
    });

And add following lines in your project’s build.zig.

    const capy_artifact = b.dependency("capy", .{}).artifact("capy");
    const capy_module = b.dependency("capy", .{}).module("capy");
    exe.linkLibrary(capy_artifact);
    exe.addModule("capy", capy_module);

I don’t recommend making modifications like this, as it changes the code of download cache. I noticed that capy has a template that you can try using instead.

3 Likes