无法在Visual Studio代码中构建c ++

时间:2019-11-09 03:27:44

标签: c++ visual-studio-code

看起来像this,只是我遵循了它,但仍然无法使其在VS Code中工作。这是我使用的目录:

C:\ Users \ EKI \ Desktop \ projects_cpp

按照说明进行操作,我将.json文件放在\ project_cpp.vscode中,并将.cpp文件放在\ projects_cpp \ helloworld中。

我的.cpp文件:

#include <iostream>


using namespace std;

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

.json文件在以下文件中:

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": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/helloworld.exe",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ]
      }
    ]
  }

settings.json

{
    "files.associations": {
        "ostream": "cpp"
    }
}

tasks.json

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

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

我尝试关闭受控文件夹的访问权限,但仍然无法正常工作。

这是错误消息

  
    

执行任务:g ++ -g c:\ Users \ EKI \ Desktop \ projects_cpp \ helloworld \ helloworld.cpp -o     $ C:\ Users \ EKI \ Desktop \ projects_cpp \ helloworld << / p>   

     

g ++。exe:错误:c:UsersEKIDesktopprojects_cpphelloworldhelloworld.cpp:   没有这样的文件或目录g ++。exe:致命错误:没有输入文件   编译终止。终端进程因退出而终止   代码:1

0 个答案:

没有答案