How to add a library to my project?

I’m new to Zig and just trying to perform basic tasks like add a library to my project.
Something as simple and straight forward as this seems not to be so simple in zig.
I have already looked through several on-line documentations but none of them worked.
Please provide guidance and I will make an effort to document the steps to add a library.
For example, to learn zig I am trying to build a simple cli app using this library (GitHub - sam701/zig-cli: A simple package for building command line apps in Zig).

What is the best way to add this to my project?
Also, I would be happy to support further documentation of these steps and perform additional documentations on other tasks.


There’s an example in the project page.


Simplest way (untested):

  1. git clone the library
  2. In your Zig program, declare `const cli = @import(“./zig-cli/src/main.zig”)
  3. zig build-exe, run

There are other ways (creating a build.zig), you have the choice.

Thank you! Following the example as directed by @LucasSantos91 has helped me.

1 Like

Note that the manifest seems outdated (wrong hash).