Troubles setting up RayLib on VScode on Windows11 for C++ programming

68 Views Asked by At

I'm having issues setting up Raylib on VScode and I think the problem stands in the debugging part of the process:

#include <raylib.h>

    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib");

    camera.position = (Vector3){10.0f, 10.0f, 8.0f};
    camera.target = (Vector3){0.0f, 0.0f, 0.0f};
    camera.up = (Vector3){0.0f, 1.0f, 0.0f};
    camera.fovy = 60.0f;
    camera.projection = CAMERA_PERSPECTIVE;


    SetTargetFPS(60);
    while (!WindowShouldClose()) // Detect window close button or ESC key
    {
        UpdateDrawFrame();
    }[enter image description here](https://i.stack.imgur.com/42Frm.png)


    CloseWindow(); // Close window and OpenGL context
    
    return 0;
}

static void UpdateDrawFrame(void)
{
    UpdateCamera(&camera, CAMERA_ORBITAL);
    
    BeginDrawing();

    ClearBackground(RAYWHITE);

    BeginMode3D(camera);

    DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
    DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
    DrawGrid(10, 1.0f);

    EndMode3D();

    DrawText("This is a raylib example", 10, 40, 20, DARKGRAY);

    DrawFPS(10, 10);

    EndDrawing();
}

When I try to run this code (a basic example you can find here) with F5 and the extension .c I face no trouble and everything works fine, but as soon as I change the file extension to .cpp, I receive this message: Debugging with .cpp extension .

On the default console I have this output:

Executing task in folder VSCode: C:\msys64\ucrt64\bin\mingw32-make.exe RAYLIB_PATH=C:/raylib/raylib PROJECT_NAME=main OBJS=main.c BUILD_MODE=DEBUG 

mingw32-make main
make[1]: Entering directory 'C:/Users/User/Desktop/raylib projects/VSCode'
make[1]: *** No rule to make target 'main.c', needed by 'main'.  Stop.
make[1]: Leaving directory 'C:/Users/User/Desktop/raylib projects/VSCode'
mingw32-make: *** [Makefile:372: all] Error 2

 *  The terminal process "C:\msys64\ucrt64\bin\mingw32-make.exe 'RAYLIB_PATH=C:/raylib/raylib', 'PROJECT_NAME=main', 'OBJS=main.c', 'BUILD_MODE=DEBUG'" terminated with exit code: 2.

I don't know if you need also the tasks.json and/or the c_cpp_properties.json but i'll add them as well:

Tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build debug",
            "type": "process",
            "command": "make",
            "args": [
                "PLATFORM=PLATFORM_DESKTOP",
                "BUILD_MODE=DEBUG",
                "PROJECT_NAME=${fileBasenameNoExtension}",
                "OBJS=${fileBasenameNoExtension}.c"
            ],
            "windows": {
                "command": "mingw32-make.exe",
                "args": [
                    "RAYLIB_PATH=C:/raylib/raylib",
                    "PROJECT_NAME=${fileBasenameNoExtension}",
                    "OBJS=${fileBasenameNoExtension}.c",
                    "BUILD_MODE=DEBUG"
                ]
            },
            "osx": {
                "args": [
                    "RAYLIB_PATH=<path_to_raylib>/raylib",
                    "PROJECT_NAME=${fileBasenameNoExtension}",
                    "OBJS=${fileBasenameNoExtension}.c",
                    "BUILD_MODE=DEBUG"
                ]
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [
                "$gcc"
            ]
        },
        {
            "label": "build release",
            "type": "process",
            "command": "make",
            "args": [
                "PLATFORM=PLATFORM_DESKTOP",
                "PROJECT_NAME=${fileBasenameNoExtension}",
                "OBJS=${fileBasenameNoExtension}.c"
            ],
            "windows": {
                "command": "mingw32-make.exe",
                "args": [
                    "RAYLIB_PATH=C:/raylib/raylib",
                    "PROJECT_NAME=${fileBasenameNoExtension}",
                    "OBJS=${fileBasenameNoExtension}.c"
                ]
            },
            "osx": {
                "args": [
                    "RAYLIB_PATH=<path_to_raylib>/raylib",
                    "PROJECT_NAME=${fileBasenameNoExtension}",
                    "OBJS=${fileBasenameNoExtension}.c"
                ]
            },
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Task generated by Debugger."
        }
    ]
}

c_cpp_properties:

{
  "configurations": [
    {
      "name": "Win32",
      "includePath": ["C:/raylib/raylib/src/**", "${workspaceFolder}/**"],
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE",
        "GRAPHICS_API_OPENGL_33",
        "PLATFORM_DESKTOP"
      ],
      "compilerPath": "C:/raylib/w64devkit/bin/gcc.exe",
      "cStandard": "c99",
      "cppStandard": "c++14",
      "intelliSenseMode": "gcc-x64"
    }
  ],
  "version": 4
}

I've been following tutorial on yt for the past 3/4 days and it's getting really frustrating because it seems like no tutorial can solve my problem, or maybe it's just my stupid ass that can't get it to work, I'm considering switching to Visual Studio but i'd like to stick on VSCode

The last one I found was this one (don't know if this may help you identifying what the problem is)

0

There are 0 best solutions below