How to compile raylib wasm game

Hey :waving_hand:
i was building my raylib sample game to wasm and i keep hitting

.cache/zig/p/raylib-5.5.0-whq8uPuyNARF5oIcIW5D0fNHVw_Zg6dB6q0DhTSjKGr-/build.zig:349:13: 0x157e5e8 in compileRaylib (build)
            @panic("Unsupported OS");

error. can anyone check what I am doing wrong here please? breakout-zig/build.zig at main · jossephus/breakout-zig · GitHub. also thanks for the help.

I created a pull request:

Thank you for taking ur time on this. This is really awesome.

1 Like

hey @Sze, with your help i was able to build it into wasm version and i was able to host it on github pages. raylib web game

i think the only thing that differs from ur PR is i am not using the sysroot to find the cache path of emscripten. I am installing emscripten using nix and turns out i can use EM_CACHE env variable to point emscripten into a new cache path. I am using this trick to install it in the current directory and using that inside our build.zig file. breakout-zig/flake.nix at main · jossephus/breakout-zig · GitHub

again Thanks for ur help.

1 Like

I don’t have much experience with nix but it looks like a nice way to freeze the emscripten version. I think I may eventually end up using it, just was too busy with other things to take a deeper look at nix.

1 Like