小编Joh*_*ter的帖子

我的 C++ 程序无法在 Visual Studio 代码上编译

我第一次尝试使用 Visual Studio Code,但我的 C++ 无法编译。

我已经将 MSYS2 中的 mingw 的 bin 和 bash.exe 添加到我的 PATH 中。我的所有代码都位于同一目录中,并且直接来自微软的指南https://code.visualstudio.com/docs/cpp/config-mingw(我确实更改了我的路径)。我的所有文件也都在同一目录中。

我已经包含了该文件

你好世界.cpp:

#include <iostream>


using namespace std;

int main()
{
   cout << "Hello World";
}
Run Code Online (Sandbox Code Playgroud)


任务.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build hello world",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "-o",
                "helloworld",
                "helloworld.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)


c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "compilerPath": "C:\\Mingw-w64\\mingw32\\bin\\g++.exe", …
Run Code Online (Sandbox Code Playgroud)

c++ windows mingw-w64 visual-studio-code

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

mingw-w64 ×1

visual-studio-code ×1

windows ×1