DEV Community

loading...

Discussion on: Setup Zig for Gamedev

Collapse
zealouswombat profile image
ZealousWombat

Got the example running on mac using a homebrew installed SDL2 using the following build.zig.

const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    const target = b.standardTargetOptions(.{ .default_target = .{ .abi = .gnu } });
    const mode = b.standardReleaseOptions();

    const exe = b.addExecutable("hello-gamedev", "src/main.zig");
    exe.setTarget(target);
    exe.setBuildMode(mode);

    exe.addIncludeDir("/usr/local/include/SDL2");
    exe.addLibPath("/usr/local/lib");
    exe.linkSystemLibrary("sdl2");
    exe.linkLibC();
    exe.install();
}
Enter fullscreen mode Exit fullscreen mode

Thanks for the example!

Collapse
fabioarnold profile image
Fabio Arnold Author • Edited

Nice one!
I think you don't even need exe.addIncludeDir and exe.addLibPath since Zig makes use of pkg-config. Given you have pkg-config installed.

Forem Open with the Forem app