SDL.zig
SDL.zig copied to clipboard
Error with windows linking when compiling with zig 0.11.0-dev.750+25d3713b0
When trying to compile the example I get the following error:
/usr/lib/zig/lib/std/build/LibExeObjStep.zig:22:28: error: 'VcpkgRoot' is not marked 'pub'
const VcpkgRoot = std.build.VcpkgRoot;
~~~~~~~~~^~~~~~~~~~
/usr/lib/zig/lib/std/build.zig:1472:1: note: declared here
const VcpkgRoot = union(VcpkgRootStatus) {
^~~~~
referenced by:
addVcpkgPaths: /usr/lib/zig/lib/std/build/LibExeObjStep.zig:972:17
link: /strg/prgm/zig/usg/lib/SDL.zig/Sdk.zig:168:12
remaining reference traces hidden; use '-freference-trace' to see all reference traces
Looking at the source code I see that it is a Windows related error and I'm on Linux, the target os tag says so. Commenting from line 165 to 306 (windows SDL2 linking) makes the error go away and the program runs just fine
The patch here is to make the following section only be available on a windows build host: https://github.com/MasterQ32/SDL.zig/blob/2fbd4b228516bf08348a3173f1446c7e8d75540a/Sdk.zig#L165-L179
Feel free to submit a PR, i can't test on windows right now
However, it is now affecting other targets.
/Users/runner/hostedtoolcache/zig/zig-macos-x86_64-0.11.0-dev.771+5d3adc568/x64/lib/std/build/LibExeObjStep.zig:22:28: error: 'VcpkgRoot' is not marked 'pub'
const VcpkgRoot = std.build.VcpkgRoot;
~~~~~~~~~^~~~~~~~~~
/Users/runner/hostedtoolcache/zig/zig-macos-x86_64-0.11.0-dev.771+5d3adc568/x64/lib/std/build.zig:1472:1: note: declared here
const VcpkgRoot = union(VcpkgRootStatus) {
^~~~~
Code:
// falsed (default)
if (option.sdl_enabled) {
// import SDL bindings
const sdl = @import("vendor/SDL2-zig/Sdk.zig");
const sdk = sdl.init(b);
example.addPackage(sdk.getNativePackage("sdl2"));
sdk.link(example, .dynamic);
}