#How to actually use a library that was saved with `zig fetch --save`
1 messages · Page 1 of 1 (latest)
bump
zig fetch --save adds it to your build.zig.zon and pins the version, if you look in it you will see the dep has a name in the struct
you take that name in your build.zig file and in this case do something like this
const cli = b.dependency("cli", .{});
exe.root_module.addImport("cli", cli.module("cli"));
the cli in the dependency is the name in the build.zig.zon file, the first cli in the addImport is what you want to import it as, so that in your files you call @import("cli") and the last one in the module is what module you are importing from the dependancy, usally it will be the same as the package name, but if its not you can go check the projects build.zig file and look for any addModule lines
also, if the project takes any options you can put them in the second parameter of the dependency, and zig will pass them on when compiling, in this case there are none, but look for b.option in the build.zig file to see what you can put.
if you have the project cloned you can also do zig build -h and it will be under Project-Specific Options