Skip to content

Create Visual Studio Project

Jeffery Myers edited this page Jul 21, 2021 · 8 revisions

Preamake Easy Setup

@JeffM2510 has made a guild to easy setup for visual studio using Premake. You can read the wiki page about it here. https://github.com/raysan5/raylib/wiki/Easy-Raylib-Setup-for-Windows-with-Visual-Studio

Get started with raylib on Visual Studio the easy way (Manual Setup)

This makes use of the template projects that have already been provided.

  1. Go to the raylib repository and download or clone the repository to your computer.
  2. In the raylib folder navigate to the raylib.sln file by going projects -> VS2017. (Don't worry about the version of VS here)
  3. Open the solution file and in the Solution Explorer right-click the core_basic_window_cpp project (Not the .cpp one) and select the Set as Startup Project
  4. This contains a sample project already, Now select the core_basic_window.cpp file too see the code you will be compiling and press F5 or the Windows local debugger button in the menu bar.
  5. All done! You should be seeing the sample project's window. To write your own games or apps you will have to rewrite on this .cpp file. Have fun! :D

The proper way

raylib 2.0 includes Visual Studio 2017 project templates for the library and some examples but maybe you want to configure the library for another Visual Studio version.

Assuming you are using Visual Studio 2017 and you downloaded raylib from github you can easily follow this step by step guide.

Configure raylib game project

  1. Create a new Console project so File > New > Project...

  2. Go under Project > Properties of Your Project Name... > C/C++ > General and include the following additional directories:

    • $(raylibSrcDir)\raylib\src
  3. Select Preprocessor and include the following preprocessor definitions (for Windows platform):

    • GRAPHICS_API_OPENGL_33
    • PLATFORM_DESKTOP
  4. Under Advanced configuration choose: Compile as C Code (/TC)

  5. Go to Linker > General and add the additional directory where raylib.lib file is located.

  6. Go to Linker > Input and add the following additional dependencies:

    • raylib.lib
  7. Apply the changes and press Ctrl + Shift + B for start building your solution.

** Alternatively, you can use vcpkg (https://github.com/microsoft/vcpkg) to automatically link the library for you when you include the header **

Note: it may be required building raylib.lib file for your specific Visual Studio version, you can do this with pre-configured Visual Studio project templates.

Clone this wiki locally