关于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"
        }
    ]
}
相关推荐
什么半岛铁盒8 分钟前
【Linux系统】Linux环境变量:系统配置的隐形指挥官
linux
Bardb24 分钟前
01__C++入门
c++·qt
Lw老王要学习40 分钟前
Linux容器篇、第一章_02Rocky9.5 系统下 Docker 的持久化操作与 Dockerfile 指令详解
linux·运维·docker·容器·云计算
橙子小哥的代码世界1 小时前
【大模型RAG】Docker 一键部署 Milvus 完整攻略
linux·docker·大模型·milvus·向量数据库·rag
weixin_457665391 小时前
C++11新标准
开发语言·c++
倔强的石头1062 小时前
【Linux指南】用户与系统基础操作
linux·运维·服务器
云上艺旅2 小时前
centos升级内核
linux·运维·centos
kaikaile19952 小时前
centos开启samba服务
linux·运维·centos
云上艺旅2 小时前
centos部署k8s v1.33版本
linux·云原生·kubernetes·centos
好多知识都想学2 小时前
Centos 7 服务器部署多网站
linux·服务器·centos