Skip to content

bradmartin333/WSL2RaylibWASM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WSL2 Raylib WASM

Example C++ game made with RayLib and emscripten on WSL2

WSL2 Setup

  • Click the windows icon in the toolbar and type Turn Windows features on or off
    • Turn on Virtual Machine Platform and Windows Subsystem for Linux
    • Confirm and reboot as prompted
    • Open Microsoft Store, search for and install Ubuntu
    • Open Ubuntu from the windows app launcher when complete
    • If it fails, download and install the x64 machine patch (Typically happens on Win11)
    • Wait for install and enter desired username as password when prompted
  • Close all windows and open Command Prompt as admin
    • wsl --update to enable X11 server
  • Python3 comes with WSL2, so we don't have to install that
  • Install CMake and build tools
    • sudo apt-get update && sudo apt-get install cmake build-essential
  • Install emscripten from source
    • cd ~
    • git clone https://github.com/emscripten-core/emsdk.git
    • cd emsdk/
    • ./emsdk install latest
    • ./emsdk activate latest
  • Install raylib from source for web
    • Install deps
      • sudo apt install vlc libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev
    • cd ~
    • git clone https://github.com/raysan5/raylib.git raylib
    • cd raylib
    • mkdir build && cd build
    • cmake -DBUILD_SHARED_LIBS=ON ..
    • make
    • sudo make install
    • export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    • export DISPLAY=:0
    • Edit /home/$USER/raylib/src/Makefile
      • Update EMSDK_PATH to be /home/$(USER)/emsdk
    • source ~/emsdk/emsdk_env.sh to activate emsdk environment variables
    • cd ~/raylib/src
    • make PLATFORM=PLATFORM_WEB
  • Clone this repo
    • cd ~
    • git clone https://github.com/bradmartin333/WSL2RaylibWASM.git
    • cd WSL2RaylibWASM
  • Build main.cpp executable named test
    • g++ main.cpp -lraylib -o test
    • ./test to run
  • Build main.cpp for wasm
    • cd ~/WSL2RaylibWASM
    • ./wasm_build.sh
      • Take a look at file to understand what is happening
    • Open build/game.html in a live server