A powerful, cross-platform template for creating a new game or application using the latest bleeding-edge source code of the raylib library.
This template is configured to support both C and C++, with the provided example being C++. It also includes optional support for raygui and rlImGui.
- Windows (Visual Studio 2022 or MinGW-w64)
- Linux (GCC/Clang)
- macOS (Clang)
- Download: Download and extract the template files.
- Rename: Rename the project folder to match the name of your game (e.g.,
My-Awesome-Game). - Choose your platform below and follow the one-time setup to install a compiler.
⚠️ Important WarningThe boilerplate
main.cppfile is configured to demonstrate bothrayguiandrlimguiat the same time.Because of this, the project will not compile with the default settings unless you either:
- Modify
src/main.cppto remove the GUI code you don't need.- Disable one of the GUI libraries in the build script (see Project Customization below).
You have two excellent options for building on Windows. Visual Studio is generally easier for debugging, while MinGW-w64 provides the open-source GCC toolchain.
One-Time Setup:
- Install Visual Studio: If you haven't already, download and install Visual Studio 2022 Community.
- Install Workload: During installation, make sure to select the "Desktop development with C++" workload. This includes the required MSVC compiler, Windows SDK, and build tools.
Building the Project:
- Run the
build.batscript by double-clicking it. This will use Premake5 to create abuilddirectory containing your Visual Studio solution (.sln) file. - Open the
.slnfile in Visual Studio. - In the Solution Explorer, right-click on your project (e.g., "raylib-template") and choose "Set as Startup Project".
- Press F5 to build and run your application.
One-Time Setup:
- Install MSYS2: Go to the official MSYS2 website and follow the instructions to install it.
- Install Toolchain: Open the MSYS2 UCRT64 terminal from your Start Menu and run the following command to install the compiler, make, and other essential tools:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
- Update Windows PATH: Add the MinGW-w64 tools to your system's PATH so they can be found by scripts.
- Press the Windows key, type
env, and select "Edit the system environment variables". - Click "Environment Variables...", select the
Pathvariable under "User variables", and click "Edit...". - Click "New" and add the following path:
C:\msys64\ucrt64\bin(assuming a default install).
- Press the Windows key, type
- Verify: Open a new Command Prompt or PowerShell window and verify the installation by typing
gcc --version. You should see the compiler version information.
Building the Project:
- Simply double-click the
clean_and_build_mingw.batscript. - This will compile your code and the output executable will be placed in the
bindirectory.
One-Time Setup:
- Install the necessary development tools. On Debian/Ubuntu-based systems, this can be done with:
sudo apt update && sudo apt install build-essential
Building the Project:
- Open a terminal in the project's root directory.
- Make the build script executable:
chmod +x build.sh - Run the script:
./build.sh - The output executable will be in the
bindirectory.
One-Time Setup:
- Install the Xcode Command Line Tools, which include Apple Clang, make, and other necessary utilities:
xcode-select --install
Building the Project:
- Open a terminal in the project's root directory.
- Make the build script executable:
chmod +x build.sh - Run the script:
./build.sh - The output executable will be in the
bindirectory.
To switch the project to C, simply:
- Rename
src/main.cpptosrc/main.c. - Modify the code within
main.cto be valid C code (the boilerplate is C++). - Re-run your build script. The build system will automatically detect the
.cextension and use a C compiler.
This template includes built-in support for two powerful GUI libraries. By default, both are enabled and will be downloaded on the first run. You can customize this behavior by editing the configuration block at the top of your build script (build.bat, clean_and_build_mingw.bat, etc.).
-
--with-raygui: Controls the official, lightweight raylib GUI library.download: (Default) Downloads and builds the library.local: Uses a local copy you provide.none: Disables and excludes the library from the build.
-
--with-rlimgui: Controls both rlImGui (a raylib backend for ImGui) and the core Dear ImGui library together.download: (Default) Downloads and builds the libraries.local: Uses local copies you provide.none: Disables and excludes the libraries from the build.
Example:
To build without raygui, you would edit build.bat or clean_and_build_mingw.bat and change the appropriate line:
- Change this:
set "RAYGUI_OPTION=download" - To this:
set "RAYGUI_OPTION=none"
You can remove the example src/main.cpp file and add your own source files to the src directory. After adding or removing files, re-run the build script to update the project and compile your code.
To target a different OpenGL version, modify your build script. Find the GRAPHICS_OPTION variable and set it to one of the following values:
opengl11(OpenGL 1.1)opengl21(OpenGL 2.1)opengl33(Default)opengl43(OpenGL 4.3)opengles2(OpenGL ES 2.0)opengles3(OpenGL ES 3.0)
Example for Windows: set "GRAPHICS_OPTION=opengl43"
Copyright (c) 2020-2025 Jeffery Myers (Thanks Jeff!) Copyright (c) 2025 Remi Teeple
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.