I am trying to build a windows executable that can run on other windows machines, but so far the executable works fine on my machine, while it hangs for 15-20 seconds on other machines and then just exits. My build.zig is the following:
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "spacer",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
if (optimize != .Debug) {
exe.subsystem = .Windows;
}
// Engine
const engine = b.createModule(.{
.root_source_file = .{ .path = "src/engine/engine.zig" },
});
exe.root_module.addImport("engine", engine);
exe.addLibraryPath(.{ .cwd_relative = "external/sdl/lib/x64" });
exe.linkSystemLibrary("SDL2");
exe.addLibraryPath(.{ .cwd_relative = "external/sdl-ttf/lib/x64" });
exe.linkSystemLibrary("SDL2_ttf");
exe.addLibraryPath(.{ .cwd_relative = "external/sdl-image/lib/x64" });
exe.linkSystemLibrary("SDL2_image");
exe.addWin32ResourceFile(.{
.file = .{ .cwd_relative = "src/spacer.rc" },
});
b.getInstallStep().dependOn(&b.addInstallArtifact(
exe,
.{ .dest_dir = .{ .override = .{ .custom = "../" } } },
).step);
}
And the entrypoint in main.zig is:
extern "kernel32" fn CreateMutexA(lpMutexAttributes: ?*const *opaque {}, bInitialOwner: w.BOOL, lpName: w.LPCSTR) callconv(w.WINAPI) w.HANDLE;
extern "user32" fn MessageBoxA(hwnd: ?w.HWND, lpText: w.LPCSTR, lpCaption: w.LPCSTR, uType: w.UINT) w.INT;
const MessageBox = struct {
const button_ok: w.UINT = 0x0;
const icon_error: w.UINT = 0x10;
};
pub export fn wWinMain(_: w.HINSTANCE, _: ?w.HINSTANCE, _: ?w.LPWSTR, _: w.INT) callconv(w.WINAPI) w.INT {