ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.65k stars 2.53k forks source link

Need document about package managing. #16381

Open So1aric opened 1 year ago

So1aric commented 1 year ago

Zig Version

0.11.0-dev.3731+c6e2e1ae4

Steps to Reproduce and Observed Behavior

I didn't find any document about package managing (with build.zig.zon). I encountered this problem, and I don't know whether it's my fault or zig's. Here is my build.zig.zon file.

.{
    .name = "xxx",
    .version = "0.0.0",
    .dependencies = .{
        .zigimg = .{
            .url = "https://github.com/zigimg/zigimg/archive/40ddb16.tar.gz",
            .hash = "12208c69b00540fe3f38893800fb6c89a9fe27b4a687de5d0462e498a43db4caeec0"
        },
    },
}

Then I add this to main.zig:

const zigimg = @import("zigimg");

After running zig build, zig said:

error: no package named 'zigimg' available within package 'root'

And I totally don't know what to do.

Expected Behavior

Have some docs~

ghost commented 1 year ago

Looks like you were able to find more information than I was. I still have no idea where the package manager is or how to invoke it, let alone how it works.

dweiller commented 1 year ago

You'll probably have to wait for 0.11 for any documentation, until then the best options will be either to look at other projects, read the build system source (lib/std/Build.zig), or ask for help in the discord. For you're case, you haven't told Zig about the zigimg module, to do that you should make a build.zig file and use const zigimg_module = std.Build.dependency("zigimg").module("zigimg"); to get a std.Build.Module that you can add to your executable.

ghost commented 1 year ago

mm, I figure I should share this article here: https://zig.news/edyu/zig-package-manager-wtf-is-zon-558e

Seems like the documentation I was looking for

benjiqq commented 1 year ago

There is a github project here https://github.com/ziglang/zig/projects/4