//root.zig
const std = @import("std");
const z = @import("zalgebra");
const c = @cImport({
@cInclude("SDL3/SDL.h");
});
pub const Renderer = struct {
window: *c.SDL_Window,
pub fn init() void {
_ = c.SDL_Init(c.SDL_INIT_VIDEO);
}
pub fn deinit() void {
c.SDL_Quit();
}
};
//main.zig
const std = @import("std");
const zig_cpugame = @import("zig_cpugame");
const root = @import("root.zig");
pub fn main() !void {
var game = root.Renderer.init();
game.deinit();
}
#No clue what's causing this to error.
1 messages · Page 1 of 1 (latest)
error: the following build command failed with exit code 1:
.zig-cache/o/36be8f30a32fd66c643c996d90074232/build /home/alpha/.config/VSCodium/User/globalStorage/ziglang.vscode-zig/zig/x86_64-linux-0.15.2/zig /home/alpha/.config/VSCodium/User/globalStorage/ziglang.vscode-zig/zig/x86_64-linux-0.15.2/lib /home/alpha/zig_cpugame .zig-cache /home/alpha/.cache/zig --seed 0x6e850313 -Z26a7d3b1a937618e run
i'm not sure why you're not getting an error, but the problem is that src/root.zig is in both the main executable module, and the other one
const mod = b.addModule("zig_cpugame", .{
// The root source file is the "entry point" of this module. Users of
// this module will only be able to access public declarations contained
// in this file, which means that if you have declarations that you
// intend to expose to consumers that were defined in other files part
// of this module, you will have to make sure to re-export them from
// the root file.
.root_source_file = b.path("src/root.zig"),
// Later on we'll use this module as the root module of a test executable
// which requires us to specify a target.
.target = target,
});
this module includes the src/root.zig file, since its specified as the root source file
main.zig also includes src/root.zig, because of the line
const root = @import("root.zig");