首页 > 解决方案 > vsCode c++ minGW no such file or directory 错误

问题描述

我是第一次学习 c++ 并遵循https://code.visualstudio.com/docs/cpp/config-mingw上的指南,但我仍然无法成功编译和运行基本程序。这是我的配置、启动和任务文件。我认为可能发生的唯一问题是我的 E: 驱动器中有代码。虽然我不认为这应该是一个问题。任何和所有的帮助表示赞赏。

配置:

{
"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${workspaceFolder}/**"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "intelliSenseMode": "gcc-x64"
    }
],
"version": 4
}

发射:

{
"version": "0.2.0",
"configurations": [

    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/helloworld.exe",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
]
}

任务:

{
"version": "2.0.0",
"tasks": [
    {
        "label": "build hello world",
        "type": "shell",
        "command": "gcc",
        "args": [
            "-g",
            "-o",
            "helloworld",
            ".vscode"
            "helloworld.cpp"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

输出是:

> Executing task: gcc -g -o helloworld .vscode helloworld.cpp <
gcc.exe: error: helloworld.cpp: No such file or directory
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.

标签: c++

解决方案


推荐阅读