0

I've been trying to setup raylib with visual studio code but my include paths seem to be messed up. whenever I try to run the program I get this error which from what I understand means that my include paths are all are not correctly set but I can't find out where I am wrong: "The preLaunchTask 'build release' terminated with exit code 2". When I click debug anyway it then tells me that main.exe file does not exist. In the terminal it also seems like the makefile is failing to make the main.obj even though in theory it shouldn't: "Fatal error: can't create obj/main.o: No such file or directory". Keep in mind that I am fairly new to game development and if you need any more information from me please let know. Thanks!

Here is the task.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build debug",
            "type": "process",
            "command": "make",
            "args": [
                "PLATFORM=PLATFORM_DESKTOP",
                "BUILD_MODE=DEBUG",
            ],
            "windows": {
                "command": "mingw32-make.exe",
                "args": [
                    "RAYLIB_PATH=C:/raylib/raylib/src/**",
                    "BUILD_MODE=DEBUG"
                ],
            },
            "osx": {
                "args": [
                    "RAYLIB_PATH=<path_to_raylib>/raylib",
                    "BUILD_MODE=DEBUG"
                ],
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [
                "$gcc"
            ]
        },
        {
            "label": "build release",
            "type": "process",
            "command": "make",
            "args": [
                "PLATFORM=PLATFORM_DESKTOP",
            ],
            "windows": {
                "command": "mingw32-make.exe",
                "args": [
                    "RAYLIB_PATH=C:/raylib/raylib",
                ],
            },
            "osx": {
                "args": [
                    "RAYLIB_PATH=<path_to_raylib>/raylib",
                ],
            },
            "group": "build",
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

And my launch.json file:

{
        "version": "0.2.0",
        "configurations": [
          {
            "name": "Debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/main",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
              {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": false
              }
            ],
            "windows": {
              "miDebuggerPath": "C:/raylib/w64devkit/bin/gdb.exe",
            },
            "osx": {
              "MIMode": "lldb"
            },
            "linux": {
              "miDebuggerPath": "/usr/bin/gdb",
            },
            "preLaunchTask": "build debug"
          },
          {
            "name": "Run",
            "type": "cppdbg",
            "request": "launch",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "program": "${workspaceFolder}/main",
            "MIMode": "gdb",
            "windows": {
              "program": "${workspaceFolder}/main.exe",
              "miDebuggerPath": "C:/raylib/w64devkit/bin/gdb.exe"
            },
            "osx": {
              "MIMode": "lldb"
            },
            "linux": {
              "miDebuggerPath": "/usr/bin/gdb"
            },
            "preLaunchTask": "build release",
          }
        ]
      }

I have changed even both the .json and the Makefile include paths but it doesn't seem to be working. That is probably still the issue but I cannot find where I am wrong. I also downloaded a vscode extension called "Makefile Tools" which could be causing more harm that good.

Hubungus
  • 1
  • 1

1 Answers1

0

I have a feeling, that you are missing a valid Makefile. I can compile the example examples/core/core_2d_camera_platformer.c without any problems, using your launch.json and tasks.json when I include the following Makefile, that I derived from the one in the raylib example folder.

Makefile

CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
INCLUDE=-I$(RAYLIB_PATH)/src
LDFLAGS=-L$(RAYLIB_PATH)/src

LDLIBS_WIN = -lraylib -lopengl32 -lgdi32 -lwinmm

ifeq ($(BUILD_MODE),DEBUG)
    CFLAGS += -g -D_DEBUG
endif


all:
    gcc -O $(INCLUDE) $(LDFLAGS) $(LDLIBS_WIN) core_2d_camera_platformer.c -o core_2d_camera_platformer
wschopohl
  • 1,567
  • 1
  • 11
  • 18