关于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"
        }
    ]
}
相关推荐
程序员AlbertTu2 小时前
# Mantissa 使用教程 — Python 版与 C++ 版
c++·python·数值运算
kkkkkkkkkk_Z2 小时前
新手自学嵌入式|学习日记:从C语言到51单片机基础(GPIO、中断、定时器与PWM篇)
linux·笔记·学习·51单片机
凤年徐2 小时前
C++ 仿 muduo 高并发服务器:日志模块
linux·服务器
Linux-lucky2 小时前
39-41-Linux学习之旅之redis缓存基础与NFS基础
linux·运维·mysql·ubuntu
Lazionr2 小时前
多态:从多种形态到运行时绑定
开发语言·c++
老当益壮梁奶奶2 小时前
ARM汇编学习笔记(六):【i.MX6ULL】时钟系统与定时器(EPIT & GPT)
c语言·arm开发·嵌入式硬件·学习·51单片机
别动我齐刘海2 小时前
ROS2 Jazzy + C++ 实战路线——ros2_control
c++·人工智能·python·opencv·机器学习·机器人·github
学linux的QQ蛋2 小时前
i.MX6ULL GIC 中断整体知识点总结和ARM时钟重点总结
arm·时钟·中断
whyutianict_vv3 小时前
云计算运维培训课程技术栈拆解:从 Linux 网络到 AI 推理的五层能力分层
linux·云计算
Navigator_Z3 小时前
LeetCode //C - 1255. Maximum Score Words Formed by Letters
c语言·算法·leetcode