-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do i install it? #61
Comments
Edit: Yo, it's me from the year 2024. Zig now has a package manager and the readme should now instruct users on how to install zig-clap. If the instructions are still unclear, do comment here so it can be improved 👍 Original comment: Right now, there is no standard way to install Zig libraries. There are a few common ways people do it:
Hope this helps. I'll leave this issue open until Zig has an official package solution. I can then make the choice to add something to the README or not. |
Thank you. If anyone has a same issue as me here's how you can use it.
|
Sorry, but currently how do I do this ? exe.addPackagePath didn't seem to work. |
This used to work so i am not sure whether this will work or not nowadays but you can try. exe.addAnonymousModule("zig-clap", .{
.source_file = .{ .path = "libs/zig-clap/clap.zig" },
}); |
That works. Thank you. |
You can also now try out the zig package manager:
.{
.name = "name-of-my-program-or-package",
.version = "0.0.0",
.dependencies = .{
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/<git-hash-or-version>.tar.gz",
.hash = "<the-hash-zig-tells-you-the-package-has>",
},
}
}
const clap = b.dependecy("clap", .{});
exe.addModule("clap", clap.module("clap")); Or, if you need multiple things to depend on const clap = b.createModule(.{
.source_file = .{ .path = "lib/zig-clap/clap.zig" },
});
exe.addModule("clap", clap); |
@Hejsil how do I make
$ zig build
/home/us-er/Documents/workspace/github/themepak/build.zig.zon:4:17: error: unsupported hash function: only sha2-256 is supported
.hash = "288d62e9fb8cbbe5f67c2644d664e3550d8b5a68646c6b32d9881304136f260b",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Oh I got it, first comment or remove $ zig build
Fetch Packages... clap... /home/us-er/Documents/workspace/github/themepak/build.zig.zon:6:20: error: url field is missing corresponding hash field
.url = "https://github.com/Hejsil/zig-clap/archive/34e068756e69e7ee51ba6f27eb9036e19984a128.tar.gz",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: expected .hash = "12206795542ab1c19251aac74db20dda4c2abf3289597dd02d52b1d70175064fb298", |
How did you find this link : |
Yup that's right. Or from here. |
swats on main [!] via ↯ v0.12.0-dev.2063+804cee3b9 ❯ zig version
0.12.0-dev.2063+804cee3b9
swats on main [!] via ↯ v0.12.0-dev.2063+804cee3b9 ❯ How to resolve this issue? |
@rawhuul Version |
OKay I will try with master version |
Any insight on using the Zig Package Manager? $ zig version
0.12.0-dev.3212+40e64245f
.{
.name = "package-name-here",
.version = "0.0.0",
.dependencies = .{
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/refs/heads/master.tar.gz",
.hash = "12203896de6eedec14712f4f1eaac8b646939cfed213c56accf231a0abb05f9dbb77",
},
},
.paths = .{
"",
},
}
const clap = b.dependency("clap", .{});
exe.root_module.addImport("clap", clap.module("clap"));
exe.linkLibrary(clap.artifact("clap")); And when I try to
If I remove
I've tried using Zig
|
You have the right code in |
In Zig 0.12 it seems like the way to do this is now (new to Zig, so this may be wrong, but it's working for me): const clap = b.dependency("clap", .{});
exe.root_module.addImport("clap", clap.module("clap")); |
To summarize: (1) Run this: zig fetch --save git+https://github.com/Hejsil/zig-clap (2) Then add @kothavade 's suggestion in const clap = b.dependency("clap", .{});
exe.root_module.addImport("clap", clap.module("clap")); Yeag this sould probably be improved. Happy Zigging. |
Hi I'm on OS X Ventura 13.6.9 and use zig 0.13.0.
This is what i have in my
I'm fairly new to Zig, so I don't understand where that MakeOptions come from. EDIT Nevermind, i did this:
And it worked. |
The installation section no longer assumes that all developers use the master branch of Zig. Instead if provides different steps depending on which Zig version developers are using. Related #61
@microspino Seems the readme still needed a bit of work. While it did mention that the master branch of zig-clap targets the master branch of Zig, this wasn't under the installation section and therefor easily missed. I've rewritten the installation section to explain how to install zig-clap both for people who use a tagged release of Zig and Zig master. Hopefully that should avoid the dance you did for others :) |
Hi i am new to zig and i would like to use this library for my project. But I don't see any install instructions on README so idk how can i use it.
The text was updated successfully, but these errors were encountered: