关于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"
        }
    ]
}
相关推荐
dessler13 分钟前
Kubernetes(k8s)-集群监控(Prometheus)
linux·运维·kubernetes
一夜沐白14 分钟前
Linux用户管理
linux·运维·服务器·笔记
猫猫头有亿点炸15 分钟前
C语言大写转小写2.0
c语言·开发语言
1白天的黑夜126 分钟前
贪心算法-860.柠檬水找零-力扣(LeetCode)
c++·算法·leetcode·贪心算法
BS_Li34 分钟前
C++类和对象(上)
开发语言·c++·类和对象
PLUS_WAVE35 分钟前
【Tools】chezmoi 跨多台不同的机器管理 dotfiles 的工具
linux·服务器·软件工程·工具·chezmoi
大鱼YY1 小时前
C语言内敛函数
c语言·内联函数
超能力MAX1 小时前
关于C++中的指针值的传递
开发语言·c++
luoqice1 小时前
基于esp32实现键值对存储读写c程序例程
c语言·开发语言
wuqingshun3141592 小时前
蓝桥杯 16. 密文搜索
c++·算法·职场和发展·蓝桥杯·深度优先