Some shell scripts to build a raylib game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jens Pitkänen 8a092819c5 Update '' 2 years ago
src Add more source files in the example 2 years ago
vendor/raylib Update to 2.5.0 2 years ago
.gitignore Initial commit 2 years ago Update '' 2 years ago Fix using multiple c files and add RPi script 2 years ago Remove unneeded link flag 2 years ago Fix using multiple c files and add RPi script 2 years ago Fix using multiple c files and add RPi script 2 years ago
windows-msvc-build.bat Fix using multiple c files and add RPi script 2 years ago

Raylib version: 2.5.0 (tag) (cloned on 2019-07-24 at a9f33c9a89)

Here are dependency-less build scripts for raylib projects.

Note: if this seems a bit naive, it is. I haven't gotten around to it, but I have plans to transform this to just a few Makefiles, one for nmake and one for the standard-conforming makes, based on the Raylib Makefile. That said, these scripts are usable, just perhaps not the most standard-conforming and even the best way to compile the small binaries. (That's more about not building a static library to link with, but just compiling the library into the object files and compiling those into the program, than using shell scripts over Makefiles.)


The scripts, as mentioned above, do not have dependencies. There's one exception to this however, and that is Windows, because Windows doesn't have a built-in C compiler. On Windows, you'll need to install Visual Studio or the [build tools][vs-tools]. If you didn't install them in the default location, write your changes around line 101 of windows-build.bat.

Script customization

First of all, the scripts have a few variables at the very top, which are supposed to be configured for each project separately:

  • GAME_NAME variable is used for the executable name.
  • SOURCES is a list of .c source files, divided by spaces, which are going to be compiled and linked with raylib to create the final executable. You can use wildcards, so if you have all your .c files in a directory called src, you can just set SOURCES to src/*.c.
  • RAYLIB_SRC should point to the raylib/src directory.

Compilation flags

  • -Os (/O1 with MSVC) is used for release builds, to save space. Since it's a good practice to make your games run on the slowest possible systems, only a few games would benefit from additional runtime performance on almost all systems. Other flags: -flto (/GL and /LTCG for MSVC) in release builds, -O0 -g (/Od /Zi for MSVC) in debug builds.
  • -Wall -Wextra -Wpedantic (/Wall for MSVC) are used for warnings.


You might notice that there are two build scripts for Windows. I wrote the mingw one for cross-compilation on Linux systems, and it should work out of the box with the correct mingw packages installed. On Arch Linux, all the dependencies are covered by mingw-w64-gcc. Note that this produces 64-bit Windows binaries, unlike the msvc script, which produces 32-bit ones.

Raylib configuration

The raylib config.h has been changed a bit from the defaults, mostly to fit my personal assumptions about what I'd probably never use. Remember to check that it's all good for you, and maybe disable some stuff you don't need as well, trim out the unneeded parts!


Linux build dependencies: X11, xcb, GL, GLX, Xext, GLdispatch, Xau, Xdmcp

Provided by:

  • Arch Linux packages: libx11, libxcb, mesa

If I've missed packages in the dependencies part, ie. you have the dependencies installed but the build script returns an error / the game doesn't run, please open an issue. If you're on a system which does not have the packages listed above and you get it working, please tell me what those are so I can add them to the list :)

Command line arguments

The build scripts accept some flags, which can be given either one at a time (-d -c -r) or in bunches (-dcr). Here's a description of all of the flags.

  • -h Describes all the flags, and a few example commands
  • -d Faster builds that have debug symbols, and enable warnings
  • -u Run upx* on the executable after compilation (before -r)
  • -r Run the executable after compilation
  • -c Remove the temp/(debug|release) directory, ie. full recompile
  • -q Suppress this script's informational prints
  • -qq Suppress all prints, complete silence
  • -v cl.exe normally prints out a lot of superficial information, as well as the MSVC build environment activation scripts, but these are mostly suppressed by default. If you do want to see everything, use this flag.

* This is mostly here to make building simple "shipping" versions easier, and it's a very small bit in the build scripts. The option requires that you have upx installed and on your path, of course.


What the command does Command
Build a release build, on Windows windows-build.bat
Build a release build, full recompile, on Linux ./ -c
Build a debug build and run, on macOS ./ -d -r
Build in debug, run, don't print at all, on Linux with sh sh -drqq


The build scripts are distributed under the CC0 license, so it's in the public domain if possible, but in any case, use it however you feel like. Raylib and its dependencies (in the vendor directory) are of course licensed under their respective licenses.