VSCode:1.61.0
Linux:Ubuntu 20.04.3 LTS
我正在尝试使用VSCode构建c++程序。当运行生成时,VSCode显示此消息。
我知道构建任务需要匹配launch.json文件的preLaunchTask和tasks.json文件的标签。我已经设置好了。
tasks.json
{
"tasks": [
{
"type": "cppbuild", // but "shell" is working
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
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": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
问题是,如果我改变";类型";tasks.json中的值,从shell到cppbuild,它不起作用,并显示类似于.的错误消息
运行构建时显示错误消息
什么是不同的";cppbuild";以及";shell";?以及如何使用";cppbuild";价值
cppbuild的Te值很好。尝试在launch.json中更改值:
"preLaunchTask": "C/C++: g++ build active file",
至:
"preLaunchTask": "cppbuild",
shell和cppbuild之间的区别在于,第一个打开BASH并运行您编写的命令,第二个cppbuild运行特定的二进制文件(或程序)。