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
emccis in your PATH. Instructions here: https://emscripten.org/docs/getting_started/downloads.html - Run:
# Remember, julia 1.10 or below
julia compile_game.jl web- Output will be in the
game_wasm/directory:game.js,game.wasm
- You can serve this directory with any static web server (e.g.,
python3 -m http.server)
- 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.