Creating a game using Julia with SDL. Compiled with StaticCompiler.jl into llvm -> wasm for web builds.
Find the latest build here: https://kyjor.itch.io/julia-web-platformer
- Julia (recommended: 1.10 or below)
- StaticCompiler.jl and StaticTools.jl Julia packages
- C compiler (e.g., gcc)
- SDL2 development libraries (for desktop build)
- Emscripten SDK (for web build)
using Pkg
Pkg.add(["StaticCompiler", "StaticTools"])Make sure Emscripten is installed and emcc is in your PATH. Instructions: https://emscripten.org/docs/getting_started/downloads.html
Also install llvm-link (e.g. sudo dnf install llvm on Fedora).
# Julia 1.10 or below
./build_web.sh
# or: julia compile_library.jl webOutput: game_wasm/game.js, game_wasm/game.wasm, game.data (assets preloaded).
Serve the repo root (not only game_wasm/) and open index.html:
python3 -m http.server
# http://localhost:8000/index.htmljulia compile_game.jl webSame game_wasm/ layout, but uses the legacy game_loop / j_init_game_state API — see index.js if you switch between builds.
./build_all.sh
# or: julia compile_library.jl desktop && ./build_host.sh
./host- Make sure SDL2 shared libraries are available in
SDLCalls/liborlibs(see below). - Run:
# Remember, julia 1.10 or below
julia compile_game.jl desktop- Output will be in the
game_desktop/directory:- Linux/macOS:
game - Windows:
game.exe
- Linux/macOS:
- Place your SDL2
.so/.dylib/.dllfiles inSDLCalls/liborlibs. - On Linux, ensure you have both
libSDL2.soandlibSDL2-2.0.so.0(symlink if needed):ln -sf libSDL2-2.0.so.0 SDLCalls/lib/libSDL2.so
- On Linux/macOS, you can run:
./game_desktop/game
- If you encounter missing library errors, ensure the libraries are present and rpath is set. You can also try:
LD_LIBRARY_PATH=SDLCalls/lib:libs ./game_desktop/game
For troubleshooting or more details, see comments in compile_game.jl.