1. 程式人生 > 其它 >vscode配置C++環境時出現的問題:gcc.exe: error: CreateProcess: No such file or directory

vscode配置C++環境時出現的問題:gcc.exe: error: CreateProcess: No such file or directory

vscode配置C++環境時出現的問題:gcc.exe: error: CreateProcess: No such file or directory

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:\\MinGW\\include\\*",
                "C:\\MinGW\\lib\\gcc\\mingw32\\9.2.0\\include\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.18362.0",
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",//改這一句
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }      
    ],
    "version": 4
}

launch.json

{
    // 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++.exe - 生成和除錯活動檔案",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "為 gdb 啟用整齊列印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++"
        }
    ]
}

tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "task g++",
            "command": "C:\\MinGW\\bin\\gcc.exe",//改這一句
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd":"C:\\MinGW\\bin"
                //"cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "偵錯程式生成的任務。"
        }
    ],
    "version": "2.0.0"
}

將"C:\\MinGW\\bin\\gcc.exe"全部均改為"C:\\MinGW\\bin\\mingw32-gcc.exe"後就解決了這個問題,具體原因不清楚,先留個記錄。