This is a premake sript to build games with raylib. Premake works by creating a build system for different platforms to use. This setup is designed to work with the following platforms/compilers
- Windows - Visual Studio 2019
- Windows - Mingw-w64 https://youtu.be/4hWm8ieg4oM
- Linux - GCC
These steps setup the basic source code needed and are applied to all platforms.
Create a folder for you game. It can be anywhere on your computer.
Download the raylib source code, from https://github.com/raysan5/raylib You can get the zip file or clone the repository in git, both will work the same. Do not use the folder from the windows installer, it does not have the correct structure.
Extract the zip file, or copy the cloned raylib repository into a folder named raylib in your game folder. source code.
This folder should contain all the raylib source code files
Make a folder for your actual game’s source code. In this case we will be starting with the “advanced game” template from the raylib sources, since it is a great place to start any project from. Be sure to copy at least one C or CPP file that has a main function into this folder. If you are unsure what to do , simply copy the code from one of the examples.
Download premake version 5.0 from https://premake.github.io/
https://premake.github.io/download.html#v5
Put the premake5 executable into your game folder.
Download the premake5.lua file from this repository https://github.com/raylib-extras/game-premake
Copy it into your game folder.
Open the premake5.lua file in notepad++ or some other text editor. Find the two instances of “YourGame” and replace them with the name of your game project.
Save the file and close it.
These are the instructions for Visual Studio 2019, do these after you do the common steps above.
Get Visual Studio from https://visualstudio.microsoft.com/downloads/ The community edition is free and is perfectly suited for game development with raylib.
Run the installer to put Visual Studio 2019 on your computer. See https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=msvc-160 for more info. Be sure to install the Desktop development with C++ and Universal Windows Platform development workflows.
Double click the premake-2019.bat file, or run it from a console. This will generate all the visual studio project files for the game. You will end up with a .sln file for your game in the root folder.
The same premake system can be used on linux, just use the command premake5 gmake instead of premake5 vs2019
Double click the sln file to open your game project in Visual Studio. It will include both your game files and the raylib library, all ready to build.
These are the instructions for Mingw-w64, do these after you do the common steps above.
devkit is a great way to get it. https://github.com/skeeto/w64devkit
Double click the premake-mingw.bat file, or run it from a console. This will generate all the makefiles for the game. You will end up with a MAKEFILE file for your game in the root folder.
Open a mingw terminal and run make in your game folder. This will build your game into the bin folder.
These are the instructions for gcc on linux, do these after you do the common steps above.
run the command premake5 gmake2. This will generate all the makefiles for the game. You will end up with a MAKEFILE file for your game in the root folder.
Run make in a terminal to build your game. This will build your game into the bin folder.
You can now build, debug, and run your game using your chosen compiler tool chain
#Optional
This builds raylib with support for OpenGL 4.3 (requires raylib 4.0)