VScode与mingw64配置C++环境,preLaunchTask“g++“已终止,退出代码为1解决办法2020

VScode与mingw64配置C++环境,preLaunchTask"g++"已终止,退出代码为1解决办法2020

直接上两个文件最后的代码

如果结构差不多,是同一版本的mingw64,可以粘贴我的代码,注意一定要把"miDebuggerPath":项改为你自己mingw64的地址,注意地址的最后一项是gdb.exe

tasks.json

tasks.json中要注意
command”: 项改为"g++",
args”:项要修改
后面的
“group”:
“presentation”:
“problemMatcher”
保持不变

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "task g++",
            "type": "shell",
            //command
            "command": "g++",
            //args
            "args": [
                "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "silent"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
}

lachun.json

lachun.json中要注意
program”:项的修改
miDebuggerPath”:项修改为mingw64的地址,注意地址的最后一项是gdb.exe

{
    // 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": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            //program
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",//注意这个位置要修改才能生成正确的程序
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            // "miDebuggerPath": "/path/to/gdb",
            //miDebuggerPath
            "miDebuggerPath": "D:\\Program Files (x86)\\mingw64\\bin\\gdb.exe",//注意这个位置采用'\\'
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++" //修改此项
        }
    ]
}

以及:有的文章说要新建一个build文件夹,实测现在已经不需要了,只不过会把 .exe文件扔在根目录下罢了
在这里插入图片描述

参考:https://blog.csdn.net/qq_40969864/article/details/103158635

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值