Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Using raylib in VSCode
VSCode is an excellent choice of code editor when it comes to raylib. Getting set up with a new VSCode project is easy.
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.
Note
Make sure you install Raylib from the official release binaries which you can findhere, ratherthan building Raylib from source (should work without changes on Windows if you install Raylib mingw release).
If you have not installed MinGW or W64DevKit yet, gohere and follow instructions to set up C/C++ in your local machine.
Additionally further steps assume that you have installed bothraylib andw64devkit inC:\raylib\ folder and your folder structure looks like this:
.├── raylib│ ├── CHANGELOG│ ├── include│ ├── lib│ ├── LICENSE│ ├── README.md│ └── src└── w64devkit ├── bin ├── COPYING.MinGW-w64-runtime.txt ├── Dockerfile ├── include ├── lib ├── libexec ├── README.md ├── share ├── src ├── VERSION.txt ├── w64devkit.exe ├── w64devkit.ini └── x86_64-w64-mingw32Feel free to install differently but do the changes to the configuration files accordingly.
Clonethis repository and follow the steps outlined there.
Copy the VSCode folder (and all its contents) from raylib/projects/VSCode (from your installed directory) to your desired project location. These files can also be foundhere.
Note
You can use theZip Tool to download only the VSCode folder as a zip.
Make sure you set the proper paths to your local build of raylib inc_cpp_properties.json andtasks.json. These will be specific to your installation of raylib.
Inc_cpp_properties.json make sure thatcompilerPath is correct:
"includePath": ["C:/raylib/raylib/src/**","${workspaceFolder}/**"],"compilerPath":"C:/raylib/w64devkit/bin/gcc.exe",
Similarly intasks.json also you have to make this change for compile to occur.
If you are on Windows and useWindows Terminal with theWindows Subsystem for Linux as your default shell, you won't be able to debug or build your game with the default settings. That's because the build configuration will try to launchcmd to open a standard Windows shell which won't exists in your Linux distribution.
To make it work, editlaunch.json in the.vscode folder so that theexternalConsole property istrue instead offalse.
Important
You need to make this changetwice i.e. you should see"externalConsole": true, in both configurations.
Install the "C/C++" VSCode extension. (From Menu -File > Preferences > Extensions)
Try launching by using the "Debug" launch configuration in the Debug tab or pressF5.
or
You can Build the game usingView > Command Palette (or Ctrl + Shift + P), TypeRun Task and pressEnter. And Select theBuild Debug option. A game executable will be created in the project folder. You can see any error in the console
Install brew, cmake and raylib, if you have not installed them yet.
- Follow the instructions onbrew to install brew.
- Install CMake through:
brew install cmake - Install Raylib through :
brew install raylib
To make your life easier, it is best to use a combination of different extensions. Luckily, we can start this by installing this particular extension pack calledC/C++ Extension Pack. It contains C/C++ utilities and CMake Tools.

You can read this article if you want to know moreCMake VScode Setup
Assuming that you have a basic knowledge about CMakeLists, we will just briefly skim through process.
If you have not modified anything to your homebrew install path, you will most likely find your raylib files in
/opt/homebrew/opt/raylib/includeand dylib files in
/opt/homebrew/opt/raylib/libFirst off, try to add the include files into your projects by:
find_path(RL_INCLUDE_DIR NAMES raylib.h PATHS /opt/homebrew/opt/raylib/include)include_directories(${RL_INCLUDE_DIR})This will remove error squiggle lines from your files if you have tried to include raylib.h
Secondly, try to add the dylib library itself and link against it
find_library(RL_LIBRARY NAMES raylib PATHS /opt/homebrew/opt/raylib/lib)Make sure you use target_link_libraries after you have use the add_executable
target_link_libraries($YOUR_PROJECT ${RL_LIBRARY})Make sure you have a main.c or main.cpp file to test whether if everything is linking properly or not
Press Ctrl+Shift+P to open up the command palette, and then search and selectCMake: Configure
After that, select the run button at the bottom of the screen (not the one at the top)
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