# How do you make a package module that links against C libraries?

**URL:** <https://ziggit.dev/t/how-do-you-make-a-package-module-that-links-against-c-libraries/5407>\
**Category:** Help\
**Tags:** build-system\
**Created:** [July 28, 2024, 11:15pm UTC](https://ziggit.dev/t/how-do-you-make-a-package-module-that-links-against-c-libraries/5407 "2024-07-28T23:15:15Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![nairou](https://ziggit.dev/user_avatar/ziggit.dev/nairou/32/3107_2.png) [@nairou](https://ziggit.dev/u/nairou)\
**Post date:** [July 30, 2024, 5:02pm UTC](https://ziggit.dev/t/how-do-you-make-a-package-module-that-links-against-c-libraries/5407/21 "2024-07-30T17:02:04Z")

</div>

Right, that’s the part I’m trying to figure out, and almost wonder if they need to be in separate `build.zig` files.

All of the C headers are implementation details within the library (currently, they’re all specific to `wayland.zig`). None of them will be used outside the library, no user should care that C files are used.

So forcing the user (or in this case, the example executable) to include them to be able to compile is not desirable.

I’ve used Zig packages in the past that internally had C headers (like GLFW wrappers), and didn’t have to deal with this, but I’m assuming that having everything in the same `build.zig` is making that separation more difficult?

---

<div class="post-metadata">

**Author:** ![Sze](https://ziggit.dev/user_avatar/ziggit.dev/sze/32/496_2.png) [@Sze](https://ziggit.dev/u/Sze)\
**Post date:** [July 30, 2024, 5:25pm UTC](https://ziggit.dev/t/how-do-you-make-a-package-module-that-links-against-c-libraries/5407/22 "2024-07-30T17:25:42Z")

</div>

I think you may need to use something like this used in raylib:

> <https://github.com/raysan5/raylib/blob/9e39788e077f1d35c5fe54600f2143423a80bb3d/src/build.zig#L314-L316>

For the headers which are used with the cImport, it seems to me that the `installHeader`-headers are then accessible for later dependencies so if you add installHeader lines to your `lib` for the headers needed by your cImport in your `module`, I think that may make those headers availailble for use in the cImport and people may be able to just depend on your `module`.  
That is my current guess, but I don’t know the details of how installHeader works and if this would be the correct/idiomatic way to bundle this stuff.

I don’t really think that it needs to be a separate `build.zig`.  
If installHeader doesn’t work, I guess we will have to look at other projects or wait for somebody who has a bit more knowledge about these things.

---

<div class="post-metadata">

**Author:** ![nairou](https://ziggit.dev/user_avatar/ziggit.dev/nairou/32/3107_2.png) [@nairou](https://ziggit.dev/u/nairou)\
**Post date:** [July 30, 2024, 5:33pm UTC](https://ziggit.dev/t/how-do-you-make-a-package-module-that-links-against-c-libraries/5407/23 "2024-07-30T17:33:47Z")

</div>

Interesting, I’m not familiar with `installHeader` so I’ll take a look at what raylib is doing. I appreciate the help!

[Previous page](https://ziggit.dev/t/how-do-you-make-a-package-module-that-links-against-c-libraries/5407.md?page=1)
