提问人:Hubungus 提问时间:6/25/2023 更新时间:6/27/2023 访问量:125
使用 raylib 时,“preLaunchTask 'build release' terminated with exit code 2” include path error in vscode when using raylib
"preLaunchTask 'build release' terminated with exit code 2" include path error in vscode when using raylib
问:
我一直在尝试使用 Visual Studio 代码设置 raylib,但我的包含路径似乎搞砸了。每当我尝试运行程序时,我都会收到此错误,据我所知,这意味着我的包含路径都没有正确设置,但我无法找出我出错的地方:“preLaunchTask'构建版本'以退出代码 2 终止”。当我无论如何单击调试时,它告诉我main.exe文件不存在。在终端中,makefile 似乎也无法进行main.obj,即使理论上它不应该:“致命错误:无法创建 obj/main.o:没有这样的文件或目录”。请记住,我对游戏开发相当陌生,如果您需要我提供更多信息,请告诉我们。谢谢!
以下是task.json文件:
{
"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"
]
}
]
}
和我的launch.json文件:
{
"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",
}
]
}
我甚至更改了 .json 和 Makefile 包含路径,但它似乎不起作用。这可能仍然是问题所在,但我找不到我错在哪里。我还下载了一个名为“Makefile Tools”的 vscode 扩展,它可能会造成更大的伤害。
答:
0赞
wschopohl
6/27/2023
#1
我有一种感觉,你缺少一个有效的 Makefile。
我可以毫无问题地编译示例,使用你的 和 当我包含以下 Makefile 时,我派生自 raylib 示例文件夹中的 Makefile。examples/core/core_2d_camera_platformer.c
launch.json
tasks.json
生成文件
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
评论