Working on GNU Linux - raysan5/raylib GitHub Wiki

Building Library

To build your raylib game for GNU/Linux you need to download raylib git repository. raylib already comes with ready-to-use makefiles and CMake system to compile source code, examples and templates.

This guide is for all GNU/Linux distros, just note that APT is used as package manager for Debian based distros.

Install required tools

You need a GCC (or alternative C99 compiler), make and git (to download raylib repo).

sudo apt install build-essential git

Optionally, you could use CMake building system.

sudo apt install cmake

Install required libraries

You need to install some required libraries; ALSA for audio, Mesa for OpenGL accelerated graphics and X11 for windowing system.

sudo apt install libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev libwayland-dev libxkbcommon-dev
sudo dnf install alsa-lib-devel mesa-libGL-devel libX11-devel libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel libatomic
Arch Linux
sudo pacman -S alsa-lib mesa libx11 libxrandr libxi libxcursor libxinerama


WARNING: Wayland building requires manual generation of some wayland specific files. GLFW support for Wayland is "experimental and incomplete". For more info check issue #2666

Building for wayland requires the following additional packages

sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel

To build raylib for Wayland, -DUSE_WAYLAND=ON should be defined in the CMake step or -DUSE_WAYLAND_DISPLAY=TRUE in Makefile.

Build raylib using make

You can compile three different types of raylib library:

  • The static library (default method)
  • The dynamic shared library (often used on Linux)
  • The web library

Download the raylib repository from Github, then compile it with:

git clone raylib
cd raylib/src/
make PLATFORM=PLATFORM_DESKTOP # To make the static version.
make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED # To make the dynamic shared version.
make PLATFORM=PLATFORM_WEB # To make web version.

Warning: if you want to compile a different type of library (static, ...), you must type make clean before the compiling.

Install the library to the standard directories, usr/local/lib and /usr/local/include, or remove it:

sudo make install # Static version.
sudo make install RAYLIB_LIBTYPE=SHARED # Dynamic shared version.

sudo make uninstall
sudo make uninstall RAYLIB_LIBTYPE=SHARED

NOTE: raylib is configurable and can be be built in a variety of ways. Please read src/Makefile, src/config.h and raylib.h itself for a full listing of available options and values.

Build raylib using CMake

Building with cmake on Linux is easy, just use the following:

git clone raylib
cd raylib
mkdir build && cd build
sudo make install

In case any dependencies are missing, cmake will tell you.

NOTE: raylib is configurable and can be be built in a variety of ways. See the CMake Build Options for a full listing of available options and values. Alternatively, you may use the curses UI provided by ccmake(1) for interactively configuring raylib.

Building Examples

If you have installed raylib with make install, Just move to the folder raylib/examples and run:


If raylib was installed with make install RAYLIB_LIBTYPE=SHARED


A more detailed command for the OpenGL ES GRAPHICS variant on Ubuntu 16.04 is:

    CFLAGS="-fPIC -I/usr/include/GL" LDFLAGS='-L/usr/local/lib/raysan5 -lGLESv2 -lglfw3'

To compile just one specific example, add flags as needed:

make core/core_basic_window PLATFORM=PLATFORM_DESKTOP

To force recompile one example:

make core/core_basic_window PLATFORM=PLATFORM_DESKTOP -B

The raylib/games folder can be made the same way as the examples. Have fun!

Link raylib with system GLFW

Instead of using the embedded GLFW, you can download GLFW3 and build it from source (it requires CMake).

cd glfw-3.2.1
sudo make install

Now with GLFW installed, you may build raylib while specifying USE_EXTERNAL_GLFW:

# or

Install on GNU Linux

If you are a packager for a Distribution not listed here, please take the time and create a raylib package.


openSUSE has raylib in the official repository. Install it via:

zypper in raylib-devel

Users of older openSUSE versions will have to add the devel:libraries:c_c++ devel project.

Add the repo, refresh sources and install raylib:

zypper ar -f
zypper ref
zypper in raylib-devel

If you have any doubt, just let me know.


Fedora has raylib in the official repository.

  • raylib-devel - needed only for development, installs runtime library too
  • raylib - runtime dependency for Fedora based systems

To install development files (for development)

Continue with:

#> dnf install raylib-devel

To install library only (for runtime)

Continue with:

#> dnf install raylib

Arch Linux

The official Arch Repository contains the raylib package. Install via:

pacman -S raylib

CentOS 7 building from source

yum -y install devtoolset-9\*
scl enable devtoolset-9 bash
cd raylib/src/

The simplest possible build command

After installing raylib from source or package manager, you can build a project with this command (modify as necessary):

cc game.c -lraylib -lGL -lm -lpthread -ldl -lrt -lX11

Creating a Makefile will help with building as the project grows.

Common issues

I get an error: error while loading shared libraries: cannot open shared object file: No such file or directory after rebooting. Right after building the library it worked fine.

If you install raylib with RAYLIB_LIBTYPE=SHARED you may find that compiler is unable to locate library file. That is because raylib wasn't installed to standard system library directories. You can check in which directory raylib was installed by looking at the make install output:

cp --update --verbose /home/<USERNAME>/<PATH_TO_RAYLIB>/raylib/ /usr/local/lib/

In this case raylib was installed to /usr/local/lib, but it can be that raylib gets installed into /usr/local/lib64 or some other directory. You should check the output yourself and make sure, that missing files are located in that directory.

Next all you need to do is either specify that install path in the makefile or set an environment variable. You can set an environment variable by typing:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib (replace /usr/local/lib with your install path)

You can append this command to the end of your ~/.bashrc or ~/.zshrc or other user login script, to make the change permanent. If you do so you'll be able to compile right away after you relogin. If you don't want to relogin just run source <YOUR USER LOGIN SCRIPT>

Simple setup using Premake

The fastest way to get a game setup on with GCC, MinGW or Visual Studio is to use premake.

See for instructions

Or watch the video tutorial here

⚠️ ** Fallback** ⚠️