visual-studio-code - vscode cpp build tasks.json 类型:“cppbuild”错误
问题描述
VSCode:1.61.0
Linux:Ubuntu 20.04.3 LTS
我正在尝试使用 VSCode 构建 c++ 程序。运行构建时,VSCode 显示此消息。
我知道构建任务需要将 launch.json 文件的 preLaunchTask 与 tasks.json 文件的标签匹配。我已经设置好了。
任务.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"
}
启动.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”值?
解决方案
推荐阅读
- android - 在 Android Studio 中实现多合一事件日历
- react-native - 如何在 React Native Expo 上使用多轮选择器
- autocomplete - 为什么我不能在 Atom IDE 中使用 Emmet 为 JSX 启用 Tab 补全
- python - Python - Pandas:拆分数据帧与两个总计
- c# - 如何在 ASP.NET 3.5 中通过 IIS7 启动与服务器桌面交互的进程?
- machine-learning - 归一化多元线性回归模型中的因变量
- python - Django 从字符字段迁移到整数字段?
- macos - PyCharm删除整行光标向上移动
- apache-pig - 猪脚本循环虽然计算平均值
- android - 无法解决:multidex-instrumentation