Hey, I just learned that I can use non-zig projects in Zig’s package manager, which is cool as hell, but I’m struggling to figure out how to use it with SDL3.
I ran this command to get the package:
zig fetch --save=SDL https://github.com/libsdl-org/SDL/archive/refs/tags/preview-3.1.6.tar.gz
Which naturally, put this in my build.zig.zon
.SDL = .{
.url = "https://github.com/libsdl-org/SDL/archive/refs/tags/preview-3.1.6.tar.gz",
.hash = "122099f4cc54e09ca76cb1b5c9d32f6809dab17c53c0d81dbc07fb3bf52c2ac8a793",
},
and then tried linking it to my project like so:
const sdl_dep = b.dependency("SDL", .{
.target = target,
});
exe.linkLibrary(sdl_dep.artifact("SDL"));
But it’s having a hard time finding artifact ‘SDL’. I’ve tried multiple other names, and I’m unsure what I’m doing wrong here. I’ve checked out these posts:
This one, I checked out Andrew’s code, and he seems to do the same thing with soundio?
This one, I didn’t understand the conclusion to
& a few others
How does this work, and how can I use this for adding SDL3 to my project? If it’s not possible, that’s fine.