A simple cross platform template for setting up a project with the bleeding edge Raylib + Raylib-cpp code. Works with C or C++.
Special thanks to HarenDev for both providing the quickstart base and the PA0 implementation.
Quickstart supports the main 3 desktop platforms:
- Windows
- Linux
- MacOS
You need to have a C++ compiler toolchain installed to be able to build this project.
- Go to official RayLib site and get the Windows installer: https://www.raylib.com/
- Run the installer. Install RayLib in
C: - To access the C++ compiler for this we will install
w64devkitinC:. This also allows for compiling C++ in general using this tool instead of msys2. You can get it at: https://github.com/skeeto/w64devkit/releases Depending on your system, get the x64 or x86 version of the .exe file. Once it’s downloaded, run it and choose where it gets extracted, again this should be inC:. Once you get the kit, you need to update your Environmental Variables and include the following path:C:\w64devkit\bin.
You need to have the raylib library installed.
To do this you need to do the following in the Terminal:
- Have XCode installed. Install it using the command:
xcode-select --install - Have Homebrew installed. Install it using the command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Install raylib:
brew install raylib
- Click the "Use This Template" button to make your own copy of this project.
- The name of the repository you create will be the name of the project when you build it.
- Clone you new project repository
- Open the folder in VSCode
- Run the build task ( CTRL+SHIFT+B or F5 )
- You are good to go
There are two compiler toolchains available for windows, MinGW-W64 (a free compiler using GCC), and Microsoft Visual Studio
- Double click the
build-MinGW-W64.batfile - CD into the folder in your terminal
- run
make CXXFLAGS=-Wno-shadow -w -j4ormingw32-make CXXFLAGS=-Wno-shadow -w -j4 - You are good to go
- Run
build-VisualStudio2022.bat - double click the
.slnfile that is generated - develop your game
- you are good to go
- CD into the build folder
- run
./premake5 gmake2 - CD back to the root
- run
make -j4 - you are good to go
You may get missing xorg depedency errors when trying to build the project. You just need to obtain the relevant xorg development packages for your relevant system.
Debian systems (such as Ubuntu):
- run
apt-get install xorg-dev - you should be good to go
- CD into the build folder
- run
./premake5.osx gmake2 - CD back to the root
- run
make -j4 - you are good to go
The built code will be in the bin dir
Run -> Start DebuggingOR- Go to the Debug Tab
- Press the play button
The example uses a utility function from path_utils.h that will find the resources dir and set it as the current working directory. This means that when accessing assets in resources we do not need to reference resources.
The resource directory will have all resources needed for the app such as images, audio, etc. Initially the project has:
imagesaudiofonts
Resource folders can be subdivided into more specific resources. For example, images could have the subfolders images/sprites and images/spritesheet.
The file that will execute the whole program will be src/main.cpp.
You can add more directories and files, but the executable will be main.cpp.
Feel free to remove the program.hpp and program.cpp files as these are just an example on how to use additional files.
- This project is based on this template supplied by a students: repo. This is made specifically for working on C++ since RayLib is mainly for working in C.
- The previous repo is based on this official template from RayLib: repo. This is purely C based.
- A cheatsheet with all functions RayLib has: cheatsheet
If you need to build for a different OpenGL version than the default (OpenGL 3.3) you can specify an OpenGL version in your premake command line. Just modify the bat file or add the following to your command line
--graphics=opengl11
--graphics=opengl21
--graphics=opengl43
--graphics=opengles2
--graphics=opengles3
Copyright (c) 2020-2025 Jeffery Myers
This software is provided "as-is", without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
-
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
-
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
-
This notice may not be removed or altered from any source distribution.