关于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"
        }
    ]
}
相关推荐
程序员yt10 分钟前
双非一本电子信息专业自学嵌入式,学完 Linux 后咋走?单片机 & FreeRTOS 要补吗?
linux·运维·单片机
楼台的春风3 小时前
【GPIO详解及实践示例】
c语言·stm32·单片机·嵌入式硬件·mcu·物联网·嵌入式
悄悄敲敲敲3 小时前
C++:dfs习题四则
c++·算法·深度优先
安於宿命5 小时前
【Linux】进程间通信——进程池
linux·c++
ll7788115 小时前
LeetCode每日精进:20.有效的括号
c语言·开发语言·算法·leetcode·职场和发展
新兴ICT项目支撑5 小时前
天翼云910B部署DeepSeek蒸馏70B LLaMA模型实践总结
linux·运维·服务器·910b·天翼云·deepseek r1
coding_rui7 小时前
链表(C语言版)
c语言·数据结构·链表
开开又心心的学嵌入式7 小时前
C语言——指针进阶应用
c语言·开发语言
coding_rui7 小时前
哈希表(C语言版)
c语言·数据结构·散列表
开开又心心的学嵌入式7 小时前
C语言——指针基础知识
c语言·开发语言