我的tasks.json是这样的,那么该怎么添加呢? { "tasks": [ { "type": "cppbuild", "label": "C/C++: gcc 生成活动文件", "command": "/usr/bin/gcc", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}", "-lstdc++" // 添加这行 ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "调试器生成的任务。" } ], "version": "2.0.0" }
时间: 2024-01-06 13:40:01 浏览: 270
许三多测试C++源码 CMakeLists.txt项目管理使用方法
非常抱歉,我之前给出的答案有误。在 `tasks.json` 文件中,`args` 字段是一个数组,所以你需要将 `-lstdc++` 添加为数组元素而不是注释。以下是正确的示例:
```json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc 生成活动文件",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lstdc++"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
```
请注意,我已将 `-lstdc++` 添加为 `args` 数组的最后一个元素。保存文件后,重新编译你的代码,看看问题是否解决了。希望这次能帮到你!
阅读全文