【发布时间】:2023-03-23 04:53:01
【问题描述】:
我正在开发 VSCode 中的 C 程序,并且我在通过 Windows 子系统 Linux (WSL 1.0) 运行 Ubuntu 20.04 的 Windows 上。过去几周一切正常,直到今天我在这篇文章的标题中遇到错误消息。我将在下面同时包含 tasks.json 和 launch.json(两者都在 .vscode 文件夹中)。
tasks.json 文件:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/gcc"
}
]
}
还有launch.json文件:
{
// 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": "gcc - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
在终端输出中,我在尝试运行基本程序时收到以下消息:
Error: The cppbuild task detection didn't contribute a task for the following configuration:
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/gcc"
}
The task will be ignored.
【问题讨论】:
-
除了将 gcc 更改为 C++ 的 g++ 之外,没有什么突出的。你也没有说你在什么情况下得到错误。猜测是您正在尝试调试。
标签: c++ c visual-studio-code vscode-debugger