Install on Linux
raylib-rs builds on Linux using the system GCC or Clang toolchain. You need the X11 and/or Wayland development headers, CMake, and the OpenGL headers. The exact package names differ by distribution.
Prerequisites
-
Rust 1.85+ — install via rustup.
-
CMake 3.15+ and build essentials — see the distribution-specific instructions below.
-
Native graphics headers — X11 + OpenGL are required for the default build. Wayland headers are optional (only needed for the
waylandfeature).
Ubuntu / Debian
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
cmake \
libasound2-dev \
libudev-dev \
libx11-dev \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxi-dev \
libgl1-mesa-dev
This is the exact package list used by the CI check.yml, test.yml, and book.yml workflows.
Fedora / RHEL / AlmaLinux
sudo dnf install -y \
cmake \
gcc-c++ \
alsa-lib-devel \
systemd-devel \
libX11-devel \
libXrandr-devel \
libXinerama-devel \
libXcursor-devel \
libXi-devel \
mesa-libGL-devel
Arch Linux
sudo pacman -S --needed \
cmake \
base-devel \
alsa-lib \
systemd-libs \
libx11 \
libxrandr \
libxinerama \
libxcursor \
libxi \
mesa
Build and run
cargo new my-raylib-game
cd my-raylib-game
cargo add raylib
cargo build
Replace src/main.rs with the hello-window snippet from the Quickstart and run with cargo run.
Wayland and DRM
- Wayland — opt in with
--features wayland. Additionally requires:- Ubuntu/Debian:
libwayland-dev libxkbcommon-dev - Fedora:
wayland-devel libxkbcommon-devel - Arch:
wayland libxkbcommon
- Ubuntu/Debian:
- DRM / tty rendering — opt in with
--features drm,opengl_es_20. Renders directly to the framebuffer without a display server; useful for embedded/kiosk targets.
Troubleshooting
-
cannot find libclang— installclangandlibclang-dev(Ubuntu:sudo apt-get install clang libclang-dev; Fedora:sudo dnf install clang). Set theLIBCLANG_PATHenvironment variable if bindgen still cannot find it. -
cmake: command not found— install cmake from your package manager (see above). -
Wayland: display server not detected — if you are running under X11 and get Wayland compositor errors, ensure you are either using the
waylandfeature intentionally or have omitted it (X11 is the default).