Elektrine lite

← Feed

@SonnyBonds@mastodon.gamedev.place

Post #600697

2026-03-07 09:17 UTC

I've got a Zig question if anyone out there happens to know. I'm wrapping the wgpu_native library into a zig build system package like in the screenshot. This works and can be consumed by another project. However, I want to _also_ package a file (include/webgpu/webgpu.h) along for the consuming project to be able to use. (I have another wrapped C library that uses webgpu as well that needs to include that header when building.) How would I do that? #zig #ziglang

Replies (4)

  • I've tried using lib.installHeader(...) which maybe works, but I can't figure out how to find/use it in the consuming project.

    Open ##1215527

  • @SonnyBonds the user can just do `b.dependency("whatever").path("include/webgpu/wgpu.h")` where whatever is the name then imported your package as in build.zig.zon.

    Open ##1215534

  • @kristoff@hachyderm.io 2026-03-07 11:18

    @SonnyBonds You have two main kinds of consumers: Zig and C (either directly or FFI). For the former you want to create zig modules, like you are doing in the screenshot, while for the latter you want to create libraries (b.addLibrary), which will also install headers that you specify via installHeader. Zig users don't need header files if you give them a translate-c module. I've recently made this package that you can use as a reference https://github.com/allyourcodebase/rnnoise notice how I'm creating: - a module that contains the full implementation (+ the translate-c output as the root file) - a module that only contains translate-c definitions in case that the user just wants those and plans to use a system-provided dynamic library - static and dynamic library artifacts for non-Zig consumers, which also install public header files. The only thing that I'm missing in that package is system integration options, which I have yet to really learn how to use.

    Open ##1215535

  • @liujiacai@mastodon.social 2026-03-07 11:22

    @SonnyBonds See https://github.com/jiacai2050/zig-curl/blob/b22007729c714936a2f85106a2fd27e0851ad567/libs/curl.zig#L26 The pattern is `deps.path('include')`.

    Open ##1215542