Jack-Ji / jok

A minimal 2d/3d game framework for @ziglang.
MIT License
172 stars 6 forks source link

Error building most basic project #14

Closed randombyte-developer closed 2 months ago

randombyte-developer commented 2 months ago

Hi!

I am trying to just set up the most basic project and build it.

$ zig version
0.13.0
$ cat build.zig
const std = @import("std");
const jok = @import("jok");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    const exe = jok.createGame(
        b,
        "mygame",
        "src/main.zig",
        target,
        optimize,
        .{},
    );
    const install_cmd = b.addInstallArtifact(exe, .{});

    const run_cmd = b.addRunArtifact(exe);
    run_cmd.step.dependOn(&install_cmd.step);

    const run_step = b.step("run", "Run game");
    run_step.dependOn(&run_cmd.step);
}
$ cat build.zig.zon 
.{
    .name = "playground",
    .version = "0.0.0",
    .dependencies = .{
        .jok = .{
            .url = "https://github.com/jack-ji/jok/archive/f0b0794dbc042e80970aff53ac14ea56a5977c27.tar.gz",
            .hash = "1220671b150b68fc3f963b790921a9356bc217bfee281f2940e793b4a5e858daa5ba",
        },
    },
    .paths = .{
        "build.zig",
        "build.zig.zon",
        "src",
    },
}
$ zig build run
/home/sven/.cache/zig/p/1220ebeeaade31e207a56977aff537a65e6338cddc68d50217ddf30bbc58fb27d367/build.zig:542:50: error: root struct of file 'Build.Step' has no member named 'MakeOptions'
    fn make(step: *Step, make_opt: std.Build.Step.MakeOptions) !void {
                                   ~~~~~~~~~~~~~~^~~~~~~~~~~~
/home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/std/Build/Step.zig:1:1: note: struct declared here
id: Id,
^~
referenced by:
    create: /home/sven/.cache/zig/p/1220ebeeaade31e207a56977aff537a65e6338cddc68d50217ddf30bbc58fb27d367/build.zig:528:31
    init: /home/sven/.cache/zig/p/1220ebeeaade31e207a56977aff537a65e6338cddc68d50217ddf30bbc58fb27d367/build.zig:155:48
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

I also tried zig's nightly but this complains about znoise missing.

randombyte-developer commented 2 months ago

Tried with nightly:

$ zig version
0.14.0-dev.591+1c35e73b6
$ zig build run
run
└─ run mygame
   └─ install mygame
      └─ zig build-exe mygame Debug native
         └─ zig build-lib znoise Debug native 1 errors
error: unable to check cache: stat file 'src/deps/znoise/libs/FastNoiseLite/FastNoiseLite.c' failed: FileNotFound
error: the following command failed with 1 compilation errors:
/home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig build-lib -cflags -std=c99 -fno-sanitize=undefined -- src/deps/znoise/libs/FastNoiseLite/FastNoiseLite.c -ODebug -I src/deps/znoise/libs/FastNoiseLite -Mroot -lc --cache-dir /home/sven/development/zig/playground/.zig-cache --global-cache-dir /home/sven/.cache/zig --name znoise -static --zig-lib-dir /home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/ --listen=- 
run
└─ run mygame
   └─ install mygame
      └─ zig build-exe mygame Debug native
         └─ zig build-lib zmesh Debug native 1 errors
error: unable to check cache: stat file 'src/deps/zmesh/libs/par_shapes/par_shapes.c' failed: FileNotFound
error: the following command failed with 1 compilation errors:
/home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig build-lib -cflags -std=c99 -fno-sanitize=undefined -DPAR_SHAPES_T=uint32_t -- src/deps/zmesh/libs/par_shapes/par_shapes.c -cflags  -- src/deps/zmesh/libs/meshoptimizer/clusterizer.cpp src/deps/zmesh/libs/meshoptimizer/indexgenerator.cpp src/deps/zmesh/libs/meshoptimizer/vcacheoptimizer.cpp src/deps/zmesh/libs/meshoptimizer/vcacheanalyzer.cpp src/deps/zmesh/libs/meshoptimizer/vfetchoptimizer.cpp src/deps/zmesh/libs/meshoptimizer/vfetchanalyzer.cpp src/deps/zmesh/libs/meshoptimizer/overdrawoptimizer.cpp src/deps/zmesh/libs/meshoptimizer/overdrawanalyzer.cpp src/deps/zmesh/libs/meshoptimizer/simplifier.cpp src/deps/zmesh/libs/meshoptimizer/allocator.cpp -cflags -std=c99 -- src/deps/zmesh/libs/cgltf/cgltf.c -ODebug -I src/deps/zmesh/libs/par_shapes -I src/deps/zmesh/libs/cgltf -Mroot -lc++ -lc --cache-dir /home/sven/development/zig/playground/.zig-cache --global-cache-dir /home/sven/.cache/zig --name zmesh -static --zig-lib-dir /home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/ --listen=- 
run
└─ run mygame
   └─ install mygame
      └─ zig build-exe mygame Debug native
         └─ zig build-lib zaudio Debug native 1 errors
error: unable to check cache: stat file 'src/deps/zaudio/src/zaudio.c' failed: FileNotFound
error: the following command failed with 1 compilation errors:
/home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig build-lib -cflags -std=c99 -- src/deps/zaudio/src/zaudio.c -cflags -DMA_NO_WEBAUDIO -DMA_NO_ENCODING -DMA_NO_NULL -DMA_NO_JACK -DMA_NO_DSOUND -DMA_NO_WINMM -std=c99 -fno-sanitize=undefined  -- src/deps/zaudio/libs/miniaudio/miniaudio.c -ODebug -I src/deps/zaudio/libs/miniaudio -Mroot -lc --cache-dir /home/sven/development/zig/playground/.zig-cache --global-cache-dir /home/sven/.cache/zig --name zaudio -static --zig-lib-dir /home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/ --listen=- 
run
└─ run mygame
   └─ install mygame
      └─ zig build-exe mygame Debug native
         └─ zig build-lib zgui Debug native 1 errors
error: unable to check cache: stat file 'src/deps/imgui/zgui/src/zgui.cpp' failed: FileNotFound
error: the following command failed with 1 compilation errors:
/home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig build-lib -cflags -fno-sanitize=undefined -- src/deps/imgui/zgui/src/zgui.cpp -cflags -fno-sanitize=undefined -- src/deps/imgui/zgui/libs/imgui/imgui.cpp src/deps/imgui/zgui/libs/imgui/imgui_widgets.cpp src/deps/imgui/zgui/libs/imgui/imgui_tables.cpp src/deps/imgui/zgui/libs/imgui/imgui_draw.cpp src/deps/imgui/zgui/libs/imgui/imgui_demo.cpp -cflags -fno-sanitize=undefined -- src/deps/imgui/zgui/libs/imgui/implot_demo.cpp src/deps/imgui/zgui/libs/imgui/implot.cpp src/deps/imgui/zgui/libs/imgui/implot_items.cpp -ODebug -I src/deps/imgui/zgui/libs -I src/deps/imgui/zgui/libs/imgui -DZGUI_IMPLOT=1 -Mroot -lc++ -lc --cache-dir /home/sven/development/zig/playground/.zig-cache --global-cache-dir /home/sven/.cache/zig --name zgui -static --zig-lib-dir /home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib/ --listen=- 
Build Summary: 10/18 steps succeeded; 4 failed
run transitive failure
└─ run mygame transitive failure
   ├─ zig build-exe mygame Debug native transitive failure
   │  ├─ zig build-lib zgui Debug native 1 errors
   │  ├─ zig build-lib zaudio Debug native 1 errors
   │  ├─ zig build-lib zmesh Debug native 1 errors
   │  └─ zig build-lib znoise Debug native 1 errors
   └─ install mygame transitive failure
      └─ zig build-exe mygame Debug native (+22 more reused dependencies)
error: the following build command failed with exit code 1:
/home/sven/development/zig/playground/.zig-cache/o/d90b653643fb7c8ffc9a04198d6ed191/build /home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/zig /home/sven/.config/Code/User/globalStorage/ziglang.vscode-zig/zig_install/lib /home/sven/development/zig/playground /home/sven/development/zig/playground/.zig-cache /home/sven/.cache/zig --seed 0x36dac2e2 -Za514cf765d50ac5e run
Jack-Ji commented 2 months ago

Yes, there is regression with nightly zig build system. It happens from time to time, unfortunately. I will keep looking into the problem.

randombyte-developer commented 2 months ago

I'm okay with downgrading zig. Do you know any working version?

Jack-Ji commented 2 months ago

Sorry for slow respond, being busy lately. I think zig 0.14.0-dev.363+c3faae6bf should be fine according to commit history. What I normally do though is wait a few days and check if nighly build works again (with a few tweaks perhaps).

randombyte-developer commented 2 months ago

Thanks. With that build I get to

sven@sven-MSI:~/development/zig/playground$ ./zig/zig build run
run
└─ run mygame
   └─ install mygame
      └─ zig build-exe mygame Debug native 9 errors
/home/sven/.cache/zig/p/1220671b150b68fc3f963b790921a9356bc217bfee281f2940e793b4a5e858daa5ba/src/deps/imgui/c/imgui_impl_sdlrenderer.cpp:42:2: error: This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function
#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function
 ^
/home/sven/.cache/zig/p/1220671b150b68fc3f963b790921a9356bc217bfee281f2940e793b4a5e858daa5ba/src/deps/imgui/c/imgui_impl_sdlrenderer.cpp:191:17: error: use of undeclared identifier 'SDL_RenderGeometryRaw'
                SDL_RenderGeometryRaw(bd->SDLRenderer, tex,
                ^
/home/sven/.cache/zig/p/1220671b150b68fc3f963b790921a9356bc217bfee281f2940e793b4a5e858daa5ba/src/deps/imgui/c/imgui_impl_sdlrenderer.cpp:227:46: error: use of undeclared identifier 'SDL_ScaleModeLinear'
    SDL_SetTextureScaleMode(bd->FontTexture, SDL_ScaleModeLinear);
...

But that is expected because Linux Mint 20.3 which is based on Ubuntu 20.04 LTS (Focal Fossa) only ships with SDL 2.0.10. Any newer LTS version is above 2.0.17. Ubuntu 22.04 LTS (Jammy Jellyfish) has 2.0.20 and Ubuntu 24.04 LTS (Noble Numbat) has 2.30.0 (SDL seems to have changed its versioning scheme).

I wanted to update my distro anyway in the next weeks. Thanks for your help :)

Jack-Ji commented 2 months ago

I have updated repo so that latest zig can compile all examples, at least on Linux platform. I'm not sure about situation of windows platform right now, cause cross-compilation seems to be broken at the moment.

MartinAbilev commented 1 month ago

i got isues on my laptop there is win11, will check with updated repo latter

Yoowhi commented 1 month ago

I've got the same issue for zig 0.13.0, MacOS Sonoma 14.4.1

Jack-Ji commented 1 month ago

Sorry, only latest zig master is supported.

MartinAbilev commented 1 month ago

sory actualy it works i need to manualy copy sdl2.dll to build directory . everything works now it amazing :D im new to zig so sometimes stupid

MartinAbilev commented 1 month ago

here https://youtu.be/kgBXFTg1x-I?t=1652 my project

Jack-Ji commented 1 month ago

@MartinAbilev Nice, have fun!