https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)

  1. Download & Setup Emscripten

    Download and install — Emscripten 4.0.11-git (dev) documentation

    cd /c
    git clone https://github.com/emscripten-core/emsdk.git
    cd emsdk
    
    # Download and install the latest SDK tools.
    ./emsdk install latest
    
    # Make the "latest" SDK "active" for the current user. (writes .emscripten file)
    ./emsdk activate latest
    
    # Activate PATH and other environment variables in the current terminal
    source ./emsdk_env.sh
    

    Add to your environment path. For example, UCRT64 MSYS2 ZSH:

    path+=("/c/emsdk/upstream/emscripten")
    

    image.png

  2. Compile Raylib with Emscripten

    You can manually compile it in command-line, See: raysan5/raylib/wiki/Working-for-Web-(HTML5)#21-command-line-compilation

    <aside>

    Currently Jai only support wasm64. So if you need to compile Raylib to wasm64 add -m64

    </aside>

    #!/usr/bin/env bash
    set -e
    
    CFLAGS="-Os -Wall -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2"
    
    emcc -c rcore.c     -o rcore.o     $CFLAGS
    emcc -c rshapes.c   -o rshapes.o   $CFLAGS
    emcc -c rtextures.c -o rtextures.o $CFLAGS
    emcc -c rtext.c     -o rtext.o     $CFLAGS
    emcc -c rmodels.c   -o rmodels.o   $CFLAGS
    emcc -c raudio.c    -o raudio.o    -m64 -Os -Wall -DPLATFORM_WEB
    
    emar rcs libraylib.a rcore.o rshapes.o rtextures.o rtext.o rmodels.o raudio.o
    

    image.png

  3. Compile our game with Emscripten

    See CMakeLists.txt