-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Working on Windows
There are several ways to get setup on Windows. This page will go through them from the easiest to the most difficult.
For compilers on Windows there are two popular choices.
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.
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.
MSYS2 Note We do not recommend using MSYS2 to get GCC, even though several tutorials suggest it. It can be difficult to configure properly and does not always include all the things needed for a complete development system. The W64-Devkit is a much better way to get the needed toolchain for building games with raylib.
The quickstart is a cross platform template for all desktop platforms that will setup raylib automatically.
https://github.com/raylib-extras/raylib-quickstart
It works with many compilers on Windows, Linux and Mac OS. Works with makefiles, visual studio, and VSCode.
Simply follow the instructions in that link and you will be done, you do not need to use the rest of this document.
This guide should work across all platforms, but the example is demonstrated on Windows.
- Download and unzip raylib to a directory, e.g.,
C:\raylib
. - Place your C file in any desired location.
- Compile the C (i.e., test.c) file using the following command:
zig cc -o test.exe test.c -I"C:\raylib\include" "C:\raylib\lib\libraylib.a" -lopengl32 -lgdi32 -lwinmm
If you do not want to use the quickstart, you have several options
- Download
w64devkit-x.xx.x.zip
from https://github.com/skeeto/w64devkit
Unzip to
c:\w64devkit
- Download
raylib-5.0_win64_mingw-w64.zip
from https://github.com/raysan5/raylib/releases
Unzip
include
andlib
toc:\w64devkit\x86_64-w64-mingw32
https://github.com/skeeto/w64devkit?tab=readme-ov-file#library-installation
-
Goto
c:\w64devkit
runw64devkit.exe
,which launches a console -
Create
raylibhelloworld.c
#include "raylib.h"
int main() {
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "raylib basic window");
SetTargetFPS(60);
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("It works!", 20, 20, 20, BLACK);
EndDrawing();
}
CloseWindow();
return 0;
}
- Compile in w64devkit.exe console:
gcc -o raylibhelloworld.exe raylibhelloworld.c -lraylib -lgdi32 -lwinmm
- Run:
./raylibhelloworld.exe
Using MinGW make tool, just navigate from command line to raylib/src/
folder and type:
make
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:
Just open raylib/src/raylib.h
source file on Notepad++ and execute (F6) the script raylib_source_compile
raylib includes all of it's own external dependencies on windows. There are only 2 system libraries that need to be linked to raylib for a game to work.
- 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.
Just open your example source file on Notepad++ and execute (F6) the script raylib_compile_execute
Using MinGW make tool, just navigate from command line to raylib/examples/
folder and type:
mingw32-make PLATFORM=PLATFORM_DESKTOP
Open w64devkit.exe
in C:\raylib\w64devkit
then cd to c:/raylib/raylib/examples/core
and type:
gcc core_basic_window.c -lraylib -lgdi32 -lwinmm
This will output a.exe
to the current directory, where you can run it with ./a.exe
.
cl gdi32.lib msvcrt.lib raylib.lib winmm.lib filename.c -Ic:\path\to\raylib\include /link /libpath:c:\path\to\raylib\lib /NODEFAULTLIB:libcmt
You can install C libraries by copying their files to 3 locations. Then you will be able to include the headers in your project files, and compile in w64devkit with the -l
flag followed by the name of the installed library.
- Copy headers (.h or .hpp) to
C:\raylib\w64devkit\x86_64-w64-mingw32\include\
- Copy libraries (.lib) to
C:\raylib\w64devkit\x86_64-w64-mingw32\lib\
- Copy executables (.dll or .exe) to
C:\raylib\w64devkit\bin\
For example, after installing lua54.dll
and lua54.lib
(along with the headers), I was able to compile with gcc main.c -o mygame -lraylib -llua54 -lopengl32 -lgdi32 -lwinmm
www.raylib.com | itch.io | GitHub | Discord | YouTube
- Architecture
- Syntax analysis
- Data structures
- Enumerated types
- External dependencies
- GLFW dependency
- libc dependency
- Platforms and graphics
- Input system
- Default shader
- Custom shaders
- Coding conventions
- Integration with other libs
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on Chrome OS
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working on exaequOS Web Computer
- Creating Discord Activities
- Working anywhere with CMake
- CMake Build Options
- raylib templates: Get started easily
- How To: Quick C/C++ Setup in Visual Studio 2022, GCC or MinGW
- How To: C# Visual Studio Setup
- How To: VSCode
- How To: Eclipse
- How To: Sublime Text
- How To: Code::Blocks