一、问题描述

按下 F5 启动调试后 ,出现如下情况

  /*“launch: program ...... does not exist”*/

/*“VSCode include<iostream>"*/

二、问题解决

我的方式很直接简单,就直接口述了,

tasks.jsonlaunch.json  删掉 重新配置(此操作不会影响你的setting.json和插件)

删掉之后,Ctrl+c 一段简单的 c++代码 , 点击运行

依次选择

等待生成新的tasks.jsonlaunch.json 文件

以上过程仅个人偶然实现,如有不足,请大佬们指出(我应该不会改的)

三、修改配置

后面就是配置修改这两个文件

教程文件    // 网址摘自 B站up主 火星动力猿

【文档包】VScode配置C语言【发布】.zip - 蓝奏云 (lanzouh.com)

  

视频链接

【教程】VScode中配置C语言/C++运行环境_哔哩哔哩_bilibili

If you are lazy(COPY)

tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "D:\\VSCode\\VScodeVScode\\MinGw\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\coin\\${fileBasenameNoExtension}.exe",
                "-fexec-charset=GBK"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

launch.json 文件
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\coin\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole":true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\VSCode\\VScodeVScode\\MinGw\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe 生成活动文件"
        }
    ]
}

运行结果

Logo

2万人民币佣金等你来拿,中德社区发起者X.Lab,联合德国优秀企业对接开发项目,领取项目得佣金!!!

更多推荐