Skip to content
veganaiZe edited this page Feb 15, 2024 · 68 revisions

Building raylib on Windows

There are several ways to get setup on windows. This page will go through them from the easiest to the most difficult.

Compilers

For compilers on windows there are two popular choices.

Visual Studio

This is the industry standard IDE for working on windows. A free version is available as the community edition. https://visualstudio.microsoft.com/vs/community/ Note Visual studio is large and somewhat resource intensive, you should have a recently modern computer to use it.

MinGW-W64/GCC

This is an open source C/C++ toolchain that is very lightweight. The best way to get MinGW-W64 and GCC is via the W64Devkit https://github.com/skeeto/w64devkit/ Download the w64devkit zip file, unzip it and run W64Devkit.exe. that will give you a terminal that is ready to go.

Note that old MinGW (Not w64) from mingw.org will not work with raylib. You need to use MinGW-w64.

Game-Premake, the simple solution to get started quickly.

The game premake system is quite honestly the simplest way to get started on windows. It is a solution that uses premake to generate a build system specifically for raylib for you. It handles everything including setting up raylib.

https://github.com/raylib-extras/game-premake

It works with many compilers on windows, linux and mac OS.

Simply follow the instructions in that link and you will be done. If you use game-premake you can ingore the rest of this document

Other methods

If you do not want to use game-premake, you have several options

Build raylib using make

Using MinGW make tool, just navigate from command line to raylib/src/ folder and type:

mingw32-make PLATFORM=PLATFORM_DESKTOP

Installing and building raylib via vcpkg

You can download and install raylib using the vcpkg dependency manager:

  git clone https://github.com/Microsoft/vcpkg.git
  cd vcpkg
  bootstrap-vcpkg.bat
  vcpkg integrate install
  vcpkg install raylib

The default triplet in vcpkg is set to "x86-windows". If you want to install x64 version instead, you should use following command:

  vcpkg install raylib:x64-windows

The raylib port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

The instructions below are focused on compiling raylib using Notepad++ as the editor and TCC or MinGW as the compiler:

Build raylib using Notepad++ script

Just open raylib/src/raylib.h source file on Notepad++ and execute (F6) the script raylib_source_compile

A note on dependencies

Raylib includes all of it's own external dependencies on windows. There are 3 system libraries that need to be linked to raylib for a game to work.

  • OpenGL32: This is the Windows interface to the OpenGL API that raylib uses for drawing.
  • GDI32: This is the interface to the window setup and drawing functions that raylib and GLFW need to work on Windows.
  • WinMM: This is contains the high resolution timer code used by GLFW for precise timing in the game loop.

Building Examples

Build example using Notepad++ script

Just open your example source file on Notepad++ and execute (F6) the script raylib_compile_execute

Build ALL examples using make

Using MinGW make tool, just navigate from command line to raylib/examples/ folder and type:

mingw32-make PLATFORM=PLATFORM_DESKTOP

Build ONE example using gcc/g++

Open w64devkit.exe in C:\raylib\w64devkit then cd to c:/raylib/raylib/examples/core and type:

gcc core_basic_window.c -lraylib -lopengl32 -lgdi32 -lwinmm

This will output a.exe to the current directory, where you can run it with ./a.exe.

Build ONE example using msvc/cl

cl gdi32.lib kernel32.lib msvcrt.lib opengl32.lib raylib.lib shell32.lib user32.lib winmm.lib filename.c -Ic:\path\to\raylib\include /link /libpath:c:\path\to\raylib\lib /NODEFAULTLIB:libcmt
Clone this wiki locally