关于vs code Debug调试时候出现“找不到任务C/C++: g++.exe build active file” 解决方法

vs code Debug调试时候出现"找不到任务C/C++: g++.exe build active file" ,出现报错,Debug失败


后来经过摸索和上网查找资料解决问题

方法如下

在Vs code的操作页面左侧有几个配置文件

红框里的是需要将要修改的文件

查看tasks.json和launch.json框选" "的字符串是否一致

完成后,按F5启动调试,报错弹窗消失,顺利完成调试

下面是 我的 Vs code中tasks.json和launch.json源文件

cpp 复制代码
{
    "tasks": [
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            }
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: /usr/bin/g++"
        }
    ],
    "version": "2.0.0"
}
cpp 复制代码
{
    // 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++ - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}
相关推荐
老猿讲编程1 小时前
C++中的奇异递归模板模式CRTP
开发语言·c++
黑翼杰克斯2 小时前
如何裁剪u-boot,保留其必要功能,使体积尽可能小
linux·1024程序员节
Yupureki2 小时前
从零开始的C++学习生活 16:C++11新特性全解析
c语言·数据结构·c++·学习·visual studio
紫荆鱼3 小时前
设计模式-迭代器模式(Iterator)
c++·后端·设计模式·迭代器模式
ScilogyHunter3 小时前
C语言标准库完全指南
c语言·开发语言
应茶茶3 小时前
C++11 核心新特性:从语法重构到工程化实践
java·开发语言·c++
jingshaoyou4 小时前
ubuntu 搭建SVN服务器
服务器·ubuntu·svn
程子的小段4 小时前
C 语言实例 - 字符串复制
c语言·开发语言
cellurw4 小时前
Day69 SQLite3动态库移植 + BMP图像解析显示 + 进度条控件设计与动态文本管理
linux
-森屿安年-4 小时前
STL 容器:stack
开发语言·c++