Hi all, this is my code:
//! build.zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// 1. Create the executable
const exe = b.addExecutable(.{
.name = "web_gpu",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libcpp = true,
.link_libc = true,
}),
});
{
const zglfw = b.dependency("zglfw", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zglfw", zglfw.module("root"));
exe.linkLibrary(zglfw.artifact("glfw"));
}
{
@import("zgpu").addLibraryPathsTo(exe);
const zgpu = b.dependency("zgpu", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zgpu", zgpu.module("root"));
exe.linkLibrary(zgpu.artifact("zdawn"));
}
{
const zmath = b.dependency("zmath", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zmath", zmath.module("root"));
}
{
const zmesh = b.dependency("zmesh", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zmesh", zmesh.module("root"));
exe.linkLibrary(zmesh.artifact("zmesh"));
}
switch (target.result.os.tag) {
.windows => {
if (target.result.cpu.arch.isX86()) {
if (target.result.abi.isGnu() or target.result.abi.isMusl()) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
exe.addLibraryPath(system_sdk.path("windows/lib/x86_64-windows-gnu"));
}
}
}
},
.macos => {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
exe.addLibraryPath(system_sdk.path("macos12/usr/lib"));
exe.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
}
},
.linux => {
if (target.result.cpu.arch.isX86()) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
exe.addLibraryPath(system_sdk.path("linux/lib/x86_64-linux-gnu"));
}
} else if (target.result.cpu.arch == .aarch64) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
exe.addLibraryPath(system_sdk.path("linux/lib/aarch64-linux-gnu"));
}
}
},
else => {},
}
// 4. Finalize Build
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
//! build.zig.zon
.{
.name = .web_gpu,
.version = "0.0.0",
.fingerprint = 0xdeceb50b29873a83, // Changing this has security and trust implications.
.minimum_zig_version = "0.15.2",
.dependencies = .{
.zglfw = .{
.url = "git+https://github.com/zig-gamedev/zglfw.git#15bf6ec59a4e1399d0c753455f69b28f09e41791",
.hash = "zglfw-0.10.0-dev-zgVDNHO2IQDy_fSdwY5U4z42rHUuKgt7T9f-qmQ3FnuL",
},
.zgpu = .{
.url = "git+https://github.com/zig-gamedev/zgpu.git#b582a62c13af1a8228f72c47ea2eaa21259760eb",
.hash = "zgpu-0.12.0-dev-nqFT5IChCACWEis11EjrBQGaA0QXEqXfsi1e6cF3_AL3",
},
.zmath = .{
.url = "git+https://github.com/zig-gamedev/zmath.git#3a5955b2b72cd081563fbb084eff05bffd1e3fbb",
.hash = "zmath-0.11.0-dev-wjwivdMsAwD-xaLj76YHUq3t9JDH-X16xuMTmnDzqbu2",
},
.dawn_x86_64_windows_gnu = .{
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-windows-gnu/archive/d3a68014e6b6b53fd330a0ccba99e4dcfffddae5.tar.gz",
.hash = "N-V-__8AAGsYnAT5RIzeAu881RveLghQ1EidqgVBVx10gVTo",
.lazy = true,
},
.dawn_x86_64_linux_gnu = .{
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-linux-gnu/archive/7d70db023bf254546024629cbec5ee6113e12a42.tar.gz",
.hash = "N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB",
.lazy = true,
},
.dawn_aarch64_macos = .{
.url = "https://github.com/michal-z/webgpu_dawn-aarch64-macos/archive/d2360cdfff0cf4a780cb77aa47c57aca03cc6dfe.tar.gz",
.hash = "N-V-__8AALVIRAIf5nfpx8-4mEo2RGsynVryPQPcHk95qFM5",
.lazy = true,
},
.dawn_x86_64_macos = .{
.url = "https://github.com/michal-z/webgpu_dawn-x86_64-macos/archive/901716b10b31ce3e0d3fe479326b41e91d59c661.tar.gz",
.hash = "N-V-__8AAIz1QAKx8C8vft2YoHjGTjEAkH2QMR2UiAo8xZJ-",
.lazy = true,
},
.zmesh = .{
.url = "git+https://github.com/zig-gamedev/zmesh#da79e85180294d0633a6fbf119199eb52e818138",
.hash = "zmesh-0.11.0-dev-oO3A5k-RCgAxtVOk3K7tIQKv7xq1066dH07iPWedfyU1",
},
.zaudio = .{
.url = "git+https://github.com/zig-gamedev/zaudio#bb93ad665b89e302d4515a36b44cb8e73eaf6766",
.hash = "zaudio-0.11.0-dev-_M-91kHvPwAlW8MCRI4XiTbTeihqB8Zspgiuw-6Gqgdz",
},
.system_sdk = .{
.url = "git+https://github.com/zig-gamedev/system_sdk#777e76828f05d5d223df47a4c0de95ae4efde884",
.hash = "system_sdk-0.3.0-dev-alwUNqAaaALJ5VoZImZo3n6prezBnQnrpziun3ZeZwcp",
},
},
.paths = .{ "build.zig", "build.zig.zon", "src", "assets", "shaders" },
}
# the error
install
└─ install web_gpu
└─ compile exe web_gpu Debug native 1 errors
error: not an ELF file
note: while parsing .zig-cache/o/3d82d2e6d18ed4db6348c3dba08d0e75/libzdawn.a
error: the following command failed with 1 compilation errors:
/home/joy/dev/tools/zig/zig build-exe .zig-cache/o/380f4dfc8d5585b2366fc0b1c4ad100c/libglfw.a .zig-cache/o/3d82d2e6d18ed4db6348c3dba08d0e75/libzdawn.a .zig-cache/o/fdb4a22f70fc9b04b0c86bc40710f4f6/libzmesh.a -ODebug -I .zig-cache/o/b89caff9180ee801e0eafc8669a3df61 -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -L /home/joy/.cache/zig/p/N-V-__8AAK7XUQNKNRnv1J6i189jtURJKjp3HTftoyD4Y4CB -L /home/joy/.cache/zig/p/system_sdk-0.3.0-dev-alwUNqAaaALJ5VoZImZo3n6prezBnQnrpziun3ZeZwcp/linux/lib/x86_64-linux-gnu --dep zglfw --dep zgpu --dep zmath --dep zmesh -Mroot=/home/joy/dev/zig/web_gpu/src/main.zig -I /home/joy/.cache/zig/p/zglfw-0.10.0-dev-zgVDNHO2IQDy_fSdwY5U4z42rHUuKgt7T9f-qmQ3FnuL/libs/glfw/include -isystem /home/joy/.cache/zig/p/system_sdk-0.3.0-dev-alwUNnYaaAJAtIdE2fg4NQfDqEKs7QCXy_qYukAOBfmF/linux/include -isystem /home/joy/.cache/zig/p/system_sdk-0.3.0-dev-alwUNnYaaAJAtIdE2fg4NQfDqEKs7QCXy_qYukAOBfmF/linux/include/wayland --dep zglfw_options -Mzglfw=/home/joy/.cache/zig/p/zglfw-0.10.0-dev-zgVDNHO2IQDy_fSdwY5U4z42rHUuKgt7T9f-qmQ3FnuL/src/zglfw.zig --dep zgpu_options --dep zpool -Mzgpu=/home/joy/.cache/zig/p/zgpu-0.12.0-dev-nqFT5IChCACWEis11EjrBQGaA0QXEqXfsi1e6cF3_AL3/src/zgpu.zig --dep zmath_options -Mzmath=/home/joy/.cache/zig/p/zmath-0.11.0-dev-wjwivdMsAwD-xaLj76YHUq3t9JDH-X16xuMTmnDzqbu2/src/root.zig .zig-cache/o/fdb4a22f70fc9b04b0c86bc40710f4f6/libzmesh.a -ODebug -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -I /home/joy/.cache/zig/p/zmesh-0.11.0-dev-oO3A5k-RCgAxtVOk3K7tIQKv7xq1066dH07iPWedfyU1/libs/cgltf --dep zmesh_options -Mzmesh=/home/joy/.cache/zig/p/zmesh-0.11.0-dev-oO3A5k-RCgAxtVOk3K7tIQKv7xq1066dH07iPWedfyU1/src/root.zig -Mzglfw_options=.zig-cache/c/a06fb2bc7e5ab1184316219d8a865f54/options.zig -Mzgpu_options=.zig-cache/c/2c266f3bc81001a422e0ba33bbfbf0c8/options.zig -Mzpool=/home/joy/.cache/zig/p/zpool-0.11.0-dev-bG692QtEAQCyqBnzSBJbJlY0-a_3v1YcjFTGmg0VBjOc/src/main.zig -Mzmath_options=.zig-cache/c/93a3c58b577942895667c3da97934ff6/options.zig -Mzmesh_options=.zig-cache/c/e3bee5f21ac0b8d108bb789899fafe65/options.zig -lX11 -ldawn -lc++ -lc --cache-dir .zig-cache --global-cache-dir /home/joy/.cache/zig --name web_gpu --zig-lib-dir /home/joy/dev/tools/zig/lib/ --listen=-
Build Summary: 10/13 steps succeeded; 1 failed
install transitive failure
└─ install web_gpu transitive failure
└─ compile exe web_gpu Debug native 1 errors
error: the following build command failed with exit code 1:
.zig-cache/o/9db573f3869119c38768951ce972a091/build /home/joy/dev/tools/zig/zig /home/joy/dev/tools/zig/lib /home/joy/dev/zig/web_gpu .zig-cache /home/joy/.cache/zig --seed 0xfcacb21e -Za7465894f89e3d64
Sanity has evaded me for a few days now as I’ve tried to find a way to resolve this error. What’s funnier is that I defo did not have this problem in a prev build. It is worth mentioning that I am using wsl. pls. Help.