Hi there,
I have a c-library called htslib and Im trying to use zig cc
to build it, and then be able to import the library into a zig project using the package manager. The project is called zights
and is online at GitHub - kcleal/zights: htslib for the zig build system
When I set eveyrthing up locally, it seems to work. So assume I have an example
zig project, I can use zights by adding this to the build.zig file:
const exe = b.addExecutable(.{
.name = "example",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const zights = b.dependency("zights", .{
.target = target,
});
exe.addIncludePath(zights.path("htslib/htslib"));
exe.addIncludePath(zights.path("htslib/cram"));
exe.linkLibrary(zights.artifact("hts"));
In build.zig.zon
I list zights using the path parameter .path = "../zights"
and everything seems to work.
However, if I try and use the GitHub repo, instead adding this:
.zights = .{
.url = "https://github.com/kcleal/zights/archive/refs/tags/v0.0.1a.tar.gz",
.hash = "1220bdf5b2bc887e2523381ccb95db034651623aae4aae7c680d52215dbe6e52fa58",
Then I get FileNotFound errors relating to zights (it doesn’t appear to exists in the build_root directory). Ive run zig fetch url
and it states that everything is up to date. I think I am probably using the wrong include path, but how do I get the correct path, I can’t see the downloaded package anywhere? Im guessing it has something to do with these lines in example/build.zig
:
const zights = b.dependency("zights", .{
.target = target,
});
exe.addIncludePath(zights.path("htslib/htslib"));
exe.addIncludePath(zights.path("htslib/cram"));
exe.linkLibrary(zights.artifact("hts"));
Thanks for any pointers!