Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我的C++;项目赢得';在visualstudio代码上编译_C++_Windows_Visual Studio Code_Mingw W64 - Fatal编程技术网

C++ 我的C++;项目赢得';在visualstudio代码上编译

C++ 我的C++;项目赢得';在visualstudio代码上编译,c++,windows,visual-studio-code,mingw-w64,C++,Windows,Visual Studio Code,Mingw W64,我试图首次使用VisualStudio代码,而我的C++将无法编译。 我已经从MSYS2将mingw的bin和bash.exe添加到我的路径中。我所有的代码都在同一个目录中,并且直接来自microsoft的指南(我确实将路径更改为我的)。我的所有文件也在同一个目录中 我已经包括了文件 helloworld.cpp: #include <iostream> using namespace std; int main() { cout << "Hello Worl

我试图首次使用VisualStudio代码,而我的C++将无法编译。

我已经从MSYS2将mingw的bin和bash.exe添加到我的路径中。我所有的代码都在同一个目录中,并且直接来自microsoft的指南(我确实将路径更改为我的)。我的所有文件也在同一个目录中

我已经包括了文件

helloworld.cpp:

#include <iostream>


using namespace std;

int main()
{
   cout << "Hello World";
}

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "compilerPath": "C:\\Mingw-w64\\mingw32\\bin\\g++.exe",
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 4
}

launch.json:

{
    "version": "0.2.0",
     "configurations": [
         {
             "name": "(gdb) Launch",
             "type": "cppdbg",
             "request": "launch",
             "program": "${workspaceFolder}/helloworld.exe",
             "args": [],
             "stopAtEntry": true,
             "cwd": "${workspaceFolder}",
             "environment": [],
             "externalConsole": false,
             "MIMode": "gdb",
             "miDebuggerPath": "C:\\Mingw-w64\\mingw32\\bin\\gdb.exe",
             "setupCommands": [
                 {
                     "description": "Enable pretty-printing for gdb",
                     "text": "-enable-pretty-printing",
                     "ignoreFailures": true
                 }
             ]
         }
     ]
 }
该文件无法生成,我不断收到相同的错误消息:

g++.exe:错误:helloworld.cpp:没有这样的文件或目录g++.exe: 致命错误:未终止任何输入文件编译。终点站 进程终止,退出代码为:1



编译器似乎无法找到源文件,请更新tasks.json以编译具有完整路径的程序

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build hello world",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "${file}",//Just
                "-o",//edit
                "${workspaceFolder}\\${fileBasenameNoExtension}"//these
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

<>这里>代码> ${file } /Cult>给出了具有扩展名(.cp)的文件的完整路径,<代码> ${WorkStudioFase}} /<代码>和 $FielBaseMeNeNoEntExo}}//C++,这也是非常不言自明的。

所示代码不是有效的C++。你的C++编译器不知道什么是“CUT”。你没有告诉你的C++应该是什么,并且在这个链接中没有找到显示的代码。尝试编译这个示例,在上面链接中给出的适当C++代码,逐字地查看,看看发生了什么。@ SAMVALSHIVCHK当前代码是有效的,但是生成命令不是。哦,我看到了,因为格式< <代码>包含< /COD>在原始问题中是不可见的。我修好了。那你在哪里安装了Mingw-w64?问题似乎是vscode找不到您的编译器。
helloworld.cpp
是否在正确的文件夹中?在我看来,
g++
似乎无法通过此输出找到您的源文件g++.exe:错误:helloworld.cpp:没有这样的文件或目录欢迎您,如果您觉得这个答案有用,请接受并投票
 That eventually worked after I exited the shell and re-opened it

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "echo",
        "type": "shell",
        "command": "g++",
        "args": [
            "-g", "main.cpp"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}
 That eventually worked after I exited the shell and re-opened it

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "echo",
        "type": "shell",
        "command": "g++",
        "args": [
            "-g", "main.cpp"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}