官方的MinGW-w64 - for 32 and 64 bit Windows - Browse Files at SourceForge.net
似乎不提供编译好的文件
然后询问ai发现了
WinLibs - 适用于 Windows 的 GCC+MinGW-w64 编译器 --- WinLibs - GCC+MinGW-w64 compiler for Windows
image.png
下载解压后填路径到path就好
image.png
之后重启电脑

vscode配置文件
File: .vscode\tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "C:\\Env\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-std=c++17"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "编译器: C:\\Env\\mingw64\\bin\\g++.exe"
        }
    ]
}

File: .vscode\settings.json

{
    "files.associations": {
        "*.embeddedhtml": "html",
        "*.cjson": "jsonc",
        "*.wxss": "css",
        "*.wxs": "javascript",
        "*.tag": "html",
        "*.obr": "oberon",
        "*.conf        ": "ssh_config",
        "stdlib.h": "c",
        "functional": "cpp",
        "unordered_map": "cpp"
    }
}

File: .vscode\c_cpp_properties.json

{
    "configurations": [
        {
            "name": "MinGW-GCC",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "compilerPath": "C:\\Env\\mingw64\\bin\\g++.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64"
        }
    ],
    "version": 4
}
Last modification:August 28, 2025
如果觉得我的文章对你有用,请随意赞赏