-
Notifications
You must be signed in to change notification settings - Fork 15
Description
As mentioned in some of the earlier issues, I found this seems to work better than my previous SDL3 Library because it seem to have a zig bindings instead of directly calling the C library, so I give it a try.
However, I seems to have some issues on loading the prebuilt library:
If I follow the example, putting the following dependencies in the zon:
.@"sdl2-prebuilt-macos" = .{
.url = "https://github.com/zig-gamedev/sdl2-prebuilt-macos/archive/f14773fa3de719b3a399b854c31eb4139d63842f.tar.gz",
.hash = "12205cb2da6fb4a7fcf28b9cd27b60aaf12f4d4a55be0260b1ae36eaf93ca5a99f03",
.lazy = true,
},
.@"sdl2-prebuilt-x86_64-windows-gnu" = .{
.url = "https://github.com/zig-gamedev/sdl2-prebuilt-x86_64-windows-gnu/archive/8143e2a5c28dbace399cbff14c3e8749a1afd418.tar.gz",
.hash = "1220ade6b84d06d73bf83cef22c73ec4abc21a6d50b9f48875f348b7942c80dde11b",
.lazy = true,
},
.@"sdl2-prebuilt-x86_64-linux-gnu" = .{
.url = "https://github.com/zig-gamedev/sdl2-prebuilt-x86_64-linux-gnu/archive/2eccc574ad909b0d00b694b10c217a95145c47af.tar.gz",
.hash = "12200ecb91c0596d0356ff39d573af83abcd44fecb27943589f11c2cd172763fea39",
.lazy = true,
},
With the given example for build.zig:
// zsdl
const zsdl = b.dependency("zsdl", .{});
exe.root_module.addImport("zsdl2", zsdl.module("zsdl2"));
@import("zsdl").link_SDL2(exe);
exe.root_module.addImport("zsdl2_ttf", zsdl.module("zsdl2_ttf"));
@import("zsdl").link_SDL2_ttf(exe);
exe.root_module.addImport("zsdl2_image", zsdl.module("zsdl2_image"));
@import("zsdl").link_SDL2_image(exe);
// Optionally use prebuilt libs instead of relying on system installed SDL...
@import("zsdl").prebuilt_sdl2.addLibraryPathsTo(exe);
if (@import("zsdl").prebuilt_sdl2.install(b, target.result, .bin, .{
.ttf = true,
.image = true,
})) |install_sdl2_step| {
b.getInstallStep().dependOn(install_sdl2_step);
}
I will get an error of sdl2-prebuilt-x86_64-windows-gnu is missing as shown:
thread 20456 panic: no dependency named 'sdl2_prebuilt_x86_64_windows_gnu' in '{path}\zig\imgui_test_take_ii\build.zig.zon'. All packages used in build.zig must be declared in this file
By observing the error message and example from wgpu, it seems that we should use .sdl2_prebuilt_x86_64_windows_gnu
instead of .@"sdl2-prebuilt-x86_64-windows-gnu"
, but if I have modified that dependency name by replacing all the dash with underline:
.sdl2_prebuilt_x86_64_windows_gnu = .{
.url = "https://github.com/zig-gamedev/sdl2-prebuilt-x86_64-windows-gnu/archive/8143e2a5c28dbace399cbff14c3e8749a1afd418.tar.gz",
.hash = "1220ade6b84d06d73bf83cef22c73ec4abc21a6d50b9f48875f348b7942c80dde11b",
.lazy = true,
},
It will throw another error, stating that the name sdl2_prebuilt_x86_64_windows_gnu
is wrong, and we should use sdl2-prebuilt-x86_64-windows-gnu
which I did previously which was also wrong.
error: name must be a valid bare zig identifier (hint: switch from string to enum literal)
.name = "sdl2-prebuilt-x86_64-windows-gnu",
Has the name of the dependency changed and the readme is outdated? Or I have done something wrong with the library?