Open mikemadden42 opened 2 weeks ago
you have to add exe.linkLibC();
to the build.zig file, but it also adds a segfault
thread 1670123 panic: index out of bounds: index 51135, len 6552
/home/sweet/repos/DOOM-fire-zig/src/main.zig:623:39: 0x103e193 in showDoomFire (DOOM-fire)
spread_px = screen_buf[doFire_idx];
^
/home/sweet/repos/DOOM-fire-zig/src/main.zig:695:17: 0x103b5e9 in main (DOOM-fire)
showDoomFire();
^
/usr/lib/zig/std/start.zig:524:37: 0x103b0fe in main (DOOM-fire)
const result = root.main() catch |err| {
^
???:?:?: 0x71a86cc38e07 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x71a86cc38e07` was not available, trace may be incomplete
???:?:?: 0x71a86cc38ecb in ??? (libc.so.6)
???:?:?: 0x103ad44 in ??? (???)
zsh: IOT instruction (core dumped) ./zig-out/bin/DOOM-fire
Thanks for reporting! I will do some sleuthing.
Thanks @const-void . The follow diff fixes the build issues I hit on Ubuntu. I'm not sure if this also works on macOS & other supported platforms.
index 2c1639c..29ece06 100644
--- a/build.zig
+++ b/build.zig
@@ -22,6 +22,8 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
+ exe.linkLibC();
+
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`).
diff --git a/src/main.zig b/src/main.zig
index b2864e3..167136b 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -5,6 +5,7 @@
//
const builtin = @import("builtin");
const std = @import("std");
+const libc = @import("libc");
const allocator = std.heap.page_allocator;
Does anyone else see this build issue on Ubuntu?