Mr_Luka 2022-03-17 10:59
浏览 505
已结题

VScode运行代码时出现“终端进程已终止,退出代码:1”,且相同代码在其他IDE中能够正常运行的问题

使用vscode写c语言代码时发现无法编译运行,在此之前对配置文件未进行过修改,且前一天程序能够正常运行
目前helloworld在vscode上也无法运行成功,报错均为
终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command D:\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\mingw64\bin\g++.exe -g 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.cpp' 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL.cpp' -o 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.exe' -I 'D:\Microsoft VS Code\VS_CODE' -std=c++17”已终止,退出代码: 1。
相同的代码在dev c++上能够正常运行

附终端报错代码、配置文件代码
终端报错:

Executing task: D:\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\mingw64\bin\g++.exe -g 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.cpp' 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL.cpp' -o 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.exe' -I 'D:\Microsoft VS Code\VS_CODE' -std=c++17 <

终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command D:\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\mingw64\bin\g++.exe -g 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.cpp' 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL.cpp' -o 'd:\Microsoft VS Code\VS_CODE\ADS\PJ1\AVL_Tree.exe' -I 'D:\Microsoft VS Code\VS_CODE' -std=c++17”已终止,退出代码: 1。

配置文件:
launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\gdb.exe",        /*修改成自己bin目录下的gdb.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++"
        }
    ]
}


tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
        "type": "shell",
        "label": "task g++",
        "command": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\g++.exe",    /*修改成自己bin目录下的g++.exe,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
        "args": [
            "-g",
            "${file}",
            //"${fileDirname}\\Lab_2_Stash.cpp", // 多个文件编译
            //"${fileDirname}\\AVL.cpp",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "-I",
            "D:\\Microsoft VS Code\\VS_CODE",      /*修改成自己放c/c++项目的文件夹,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
            "-std=c++17"
        ],
        "options": {
            "cwd": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin"    /*修改成自己bin目录,这里的路径和电脑里复制的文件目录有一点不一样,这里是两个反斜杠\\*/
        },
        "problemMatcher":[
            "$gcc"
        ],
        "group": "build",
        
        }
    ]
}


c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": ["${workspaceFolder}/**"],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.17763.0",
            "compilerPath": "D:\\x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0\\mingw64\\bin\\g++.exe", 
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}"
        }
    ],
    "version": 4
}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 3月25日
    • 修改了问题 3月17日
    • 修改了问题 3月17日
    • 创建了问题 3月17日

    悬赏问题

    • ¥200 PDF使用虚拟列表技术做渲染和加载带来的问题
    • ¥15 出现报错Debug Assertion Failed,如何解决?
    • ¥50 mcf中怎么实现导入的图片变成透明
    • ¥15 ruoyi-flowable流程设计配置的表单时,级联选择如何配置
    • ¥20 金属玻璃的剪切局部化程度怎么用ovito表示出来
    • ¥15 自定义控件在中文模式下不能输入数字
    • ¥15 关于#运维#的问题:用mail.abc.com 端口9696的方式同样能访问hr.abc.com 端口:6080 的页面两个网址都指向同一个外网ip(相关搜索:服务器)
    • ¥15 xgboost建模输出结果由三分类变成四分类
    • ¥15 Windows X86 远线程注入问题解惑
    • ¥15 Vs2022安装时黑框闪退无反应