I am developing a game engine + game in C and I’ve wanted to integrate the Zig build system so that I can have easily reproducible builds and static cross-platform dependencies and I’ve gotta say my experience has been excellent so far, except that I’ve come across this issue where, even though SDL3 is accessible to me through Zig (as I am using the wrapper by gota7 so that I can begin porting parts of my engine to Zig), the headers don’t seem to be accessible to the C files themselves.
Here’s the source code, I apologize for the mess, I abandoned this sloppily made game jam game a while ago and just recently retook the project: nelson/socks/src/branch/main
“b” is the *std.Build pointer that gets passed into your build function automatically.
b.path() is a shorthand for creating a structure called std.Build.LazyPath, which is (usually used as) a path relative to the CWD of the build process and is slightly more robust than using string literals as paths.
yeah but wouldn’t that require me to have the SDL headers on my repository instead of getting them from the SDL library i’m already including in my build.zig.zon file?
Yeah.
There are ways around it.
There’s a good library you can import as a dependency (GitHub - castholm/SDL: SDL ported to the Zig build system) which sidesteps all of this.
Failing that, you can try using the std.Build.Dependency.path() function to get a path relative to the dependency root - that way you should be able to add an include path without having to merge the dependencie’s file into your project.
i mean… i already do that, it’s imported by the wrapper library i am using, that’s why i am asking how could i get zig to import whatever that library is exporting
an idea i am having right now would be to somehow get a dependency instance’s dependency instance and get the lazypath from that… hmm
@darltrash is it necessary to take a wrapper for SDL3? Zig build system allowed me to go without any binding. In my project, I set SDL3 itself as dependency in build.zig.zon and called the CMake from the Zig build script. The link if you are curious