C++ Project Setup Made Simple: Raylib, CMake, and VSCode Guide

C++ Project Setup Made Simple: Raylib, CMake, and VSCode Guide

Set up a C++ project with Raylib, CMake, and VSCode. Learn to install tools, configure vcpkg, create a project, and run your first Raylib app step by step.

This is Rambod and today we set up a complete C++ project environment with Raylib, CMake, and Visual Studio Code. This guide is designed for beginners who want a reliable workflow with the right tools and no wasted time.

1) Install the required tools

You will need:

After downloading:

If they respond, everything is installed correctly.

2) Create your project folder

Reload VSCode to finalize.

3) Initialize CMake in VSCode

4) Set up vcpkg dependencies

{
  "name": "my-raylib-project",
  "version-string": "0.1.0",
  "dependencies": [ "raylib" ]
}

5) Update CMakeLists.txt

6) Write your first Raylib program

Replace the default main.cpp with:

#include "raylib.h"

int main() {
    InitWindow(800, 600, "My Raylib Project");
    SetTargetFPS(60);

    while (!WindowShouldClose()) {
        BeginDrawing();
        ClearBackground(RAYWHITE);
        DrawText("Hello from Raylib!", 200, 280, 20, BLACK);
        DrawFPS(10, 10);
        EndDrawing();
    }

    CloseWindow();
    return 0;
}

This creates a window, displays text, and shows FPS.

7) Build and run

You should now see your Raylib window up and running.

8) Troubleshooting tips

Wrap up

You now have a complete C++ project setup with Raylib, CMake, and VSCode. This foundation makes it easy to expand with more libraries like SDL, ImGui, or fmt using the same workflow.

For more C++ tutorials and game dev tips, visit rambod.net, subscribe on YouTube, or watch this tutorial here: Watch on YouTube.