gpt4 book ai didi

linux - Visual Studio 代码调试器错误 : "Could not find the task ' gcc build active file'

转载 作者:行者123 更新时间:2023-12-02 09:37:25 25 4
gpt4 key购买 nike

我正在尝试使用 Ubuntu Linux 在 Visual Studio Code 中配置 C/C++ 工作区,但我不知道如何使调试器正常工作。我从互联网上复制了一个“tasks.json”文件,以便能够通过按下 F5 来编译我的代码,但我认为它会导致调试器出现某种问题,因为每次我尝试进入 Debug模式时,都会出现错误“Could找不到任务“gcc 构建事件文件”弹出。
这是2个jsons:
任务文件

{
"version": "2.0.0",
"tasks": [
{
"label": "debug",
"type": "shell",
"command": "",
"args": [
"g++",
"-g",
"${relativeFile}",
"-o",
"a.exe"
]
},
{
"label": "Compile and run",
"type": "shell",
"command": "",
"args": [
"g++",
"-g",
"${relativeFile}",
"-o",
"${fileBasenameNoExtension}.out",
"&&",
"clear",
"&&",
"./${fileBasenameNoExtension}.out"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"type": "shell",
"label": "g++ build active file",
"command": "/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]

}

启动文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "gcc build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]

}

在此先感谢您的帮助,我真的很无能为力。

最佳答案

在您的 task.json文件,没有任务被标记为“gcc 构建事件文件”,这是 preLaunchTask 所必需的在 launch.json文件。

因此,您可以更改 label任务或更改preLaunchTask的内容使它们匹配。

只需更改preLaunchTask的内容即可进入“g++ 构建事件文件”。它会起作用。

关于linux - Visual Studio 代码调试器错误 : "Could not find the task ' gcc build active file',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59106732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com