Search code examples
emscriptenraylib

Compiling raylib for html5/wasm


I'm trying to compile raylib for html5, but I can't seem to run make properly. Running make PLATFORM=PLATFORM_WEB -B in raylib/src returns this:

emcc -c rcore.c -Wall -D_DEFAULT_SOURCE -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing -std=gnu99 -Os -I. -Iexternal/glfw/include -Iexternal/glfw/deps/mingw -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2
make: emcc: Command not found
make: *** [Makefile:558: rcore.o] Error 127

However, running emcc works fine in the current shell (prints no input files), sh and bash, and works in different terminal emulators. $PATH is (from zsh and alacritty, my primary shell and terminal emulator):

/home/user/emsdk:/home/user/emsdk/upstream/emscripten:/home/user/emsdk/node/14.15.5_64bit/bin:/opt/devkitpro/tools/bin:/home/user/.local/bin:/home/user/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Solution

  • Despite the fact that emsdk is installed, following current (as at 8 Jan '22) documentation will not result in working examples. Build would be failed.

    In order to build it on Ubuntu with make --version GNU Make 4.2.1 you need to provide -e option to pass environment variables to make

    Then, after build is finished -- start python http server in examples directory and navigate to that address in browser: python3 -m http.server 9999 open http://localhost:9999 and select desired example.