# What is the ideomatic way to import a basic C library?

**URL:** <https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583>\
**Category:** Help\
**Tags:** c, build-system\
**Created:** [March 11, 2026, 6:05pm UTC](https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583 "2026-03-11T18:05:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kartoffelsaft](https://ziggit.dev/letter_avatar_proxy/v4/letter/k/94ad74/32.png) [@kartoffelsaft](https://ziggit.dev/u/kartoffelsaft)\
**Post date:** [March 11, 2026, 6:05pm UTC](https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583/1 "2026-03-11T18:05:32Z")

</div>

Hello!

I’ve been trying to add [microui](https://github.com/rxi/microui) as a dependency for my project. I initially tried to `zig fetch --save …` as I normally do, but because it’s missing a build.zig.zon file in it’s root that doesn’t work. I can think of a few ways to go about this but they all feel wrong:

- fork it and add a build.zig.zon file, fetch the fork instead
  - feels the most “correct” but means I’m left maintaining it somehow. That’s not as hard as I’m making it out to be but it’s still uncomfortable

- fetch without `--save` at build time (like discussed [here](https://ziggit.dev/t/fetching-dependencies-without-build-zig-zon/6236/9))
  - easily takes the most work of any of these options, and only seems to be worth doing in very odd circumstances

- add it as a git submodule
  - I’d do this for a C/C++ project, but only as a “least bad” option. It’s worse here because deps would be split between build.zig.zon and .gitmodules

- add it to a vendor directory
  - probably what I’ll do in the absence of any advice because it’s the easiest, but this incurs some of the maintenance issues of forking while also throwing out any tooling to handle dependencies

- make it a system dependency
  - means that others (or future me) will have to go through extra steps for `zig build` to work

This feels like it should be pretty easy considering zig/c interop has generally felt nice, so I’m mildly embarrassed that I can’t figure this out.

---

<div class="post-metadata">

**Author:** ![alanza](https://ziggit.dev/user_avatar/ziggit.dev/alanza/32/6006_2.png) [@alanza](https://ziggit.dev/u/alanza)\
**Post date:** [March 11, 2026, 6:19pm UTC](https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583/2 "2026-03-11T18:19:45Z")

</div>

`zig fetch --save=microui` will add the tarball to `build.zig.zon` with the name `microui`.

`build.zig.zon` (if you crack it open) is designed to be human-editable, and `zig build` will correct you if you miss, for example, the checksum.

---

<div class="post-metadata">

**Author:** ![Southporter](https://ziggit.dev/user_avatar/ziggit.dev/southporter/32/2500_2.png) [@Southporter](https://ziggit.dev/u/Southporter)\
**Post date:** [March 11, 2026, 6:20pm UTC](https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583/3 "2026-03-11T18:20:03Z")

</div>

> [@kartoffelsaft](#):
>
> `zig fetch --save …` as I normally do, but because it’s missing a build.zig.zon file in it’s root that doesn’t work.

For dependencies without a `build.zig.zon` file, you can use `zig fetch --save=name ...` to grab the dependency. So `zig fetch --save=microui ...`

---

<div class="post-metadata">

**Author:** ![kartoffelsaft](https://ziggit.dev/letter_avatar_proxy/v4/letter/k/94ad74/32.png) [@kartoffelsaft](https://ziggit.dev/u/kartoffelsaft)\
**Post date:** [March 11, 2026, 7:06pm UTC](https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583/4 "2026-03-11T19:06:25Z")

</div>

I was already aware that build.zig.zon is human-editable. I was just under the impression, through a series of misreadings, that the build system doesn’t know what to do _at all_ with a zip not containing it, and figured that `--name=...` was to prevent two dependencies of the same name causing conflicts. Thanks though!

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [March 12, 2026, 2:03am UTC](https://ziggit.dev/t/what-is-the-ideomatic-way-to-import-a-basic-c-library/14583/5 "2026-03-12T02:03:36Z")

</div>

> [@kartoffelsaft](#):
>
> figured that `--name=...` was to prevent two dependencies of the same name causing conflicts

it is, well its more general than that. It provides the name call it in `build.zig.zon` and `buid.zig`.

Prevent conflicting names is one use. Providing a name for things that don’t have a `build.zig.zon` (that’s where `zig fetch` gets the name from) like a c dependency is another use.
