Skip to content
 
 

Repository files navigation

raylib-cpp-cmake-template

Native Build Web Build

Build system and instructions copied from SasLuca/raylib-cpp-cmake-template

Note: Default project name is MyRaylibProject. When using this template, use the Search function in VS Code to find + replace all instances of this name

Building to Web

You need to install Emscripten Download Here!

  1. Clone the repository using Git. Execute this in a terminal: git clone https://github.com/gavinskycastle/MyRaylibProject.git
  2. Cd into MyRaylibProject. cd MyRaylibProject
  3. Install the required build tools (for example on Arch, type sudo pacman -S cmake make gcc pkg-config wayland-protocols)
  4. Install the raylib git submodule using git submodule update --init --recursive --depth=1
  5. Make a build folder. Your builds will go here. mkdir build; cd build
  6. Setup cmake emcmake cmake -S .. -D CMAKE_BUILD_TYPE=Release
  7. Run cmake --build build to compile the project
  8. Run a local web server and open the MyRaylibProject.html

Building (Linux/macOS)

  1. Clone the repository using git clone https://github.com/gavinskycastle/MyRaylibProject.git
  2. Move to the MyRaylibProject directory cd MyRaylibProject
  3. Install the raylib git submodule using git submodule update --init --recursive --depth=1
  4. Install the required build tools (for example on Arch, type sudo pacman -S cmake make gcc)
  5. Make a build folder and cd to it with mkdir build && cd build
  6. Setup cmake cmake .. -DCMAKE_BUILD_TYPE=Release
  7. Run make to compile the project
  8. Make the binary executable chmod +x MyRaylibProject
  9. Run the binary with ./MyRaylibProject

Building (Windows, MinGW-w64)

You need to install MinGW-w64. Copy the folder and add C:\mingw64\bin to PATH Download MinGW-w64 here!

  1. Clone the repository using Git. Execute this in a terminal: git clone https://github.com/gavinskycastle/MyRaylibProject.git
  2. Cd into MyRaylibProject. cd MyRaylibProject
  3. Install the raylib git submodule using git submodule update --init --recursive --depth=1
  4. Make a build folder. Your builds will go here. mkdir build; cd build
  5. Setup CMake. Make sure to define MinGW Makefiles if you are using MinGW-w64! cmake .. -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" You might also want to set the default generator to MinGW.
  6. Make sure you have mingw32-make. If you do, just run it in the build directory and it will start compiling everything. It won't take long, and once it's finished, then
  7. Run MyRaylibProject.exe! You have just compiled MyRaylibProject for Windows using MinGW.

Building (Windows, MSVC)

You need to have Visual Studio 2019 (other versions aren't tested, please tell us if it works for you) with C++ Development selected in the installer.

  1. Clone the repository using Git. Execute this in a terminal: git clone https://github.com/gavinskycastle/MyRaylibProject.git
  2. Cd into MyRaylibProject. cd MyRaylibProject
  3. Install the raylib git submodule using git submodule update --init --recursive --depth=1
  4. Make a build folder. Your builds will go here. mkdir build; cd build
  5. Setup CMake. cmake .. -DCMAKE_BUILD_TYPE=Release
  6. Let's build the project! Run cmake --build .
  7. Go into Debug, your build of MyRaylibProject is there. You have now compiled MyRaylibProject for Windows using MSVC.

About

A simple and portable raylib cmake template using C++

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages