【问题标题】:Run simple C++ program in Visual Studio Code在 Visual Studio Code 中运行简单的 C++ 程序
【发布时间】:2020-10-06 22:07:51
【问题描述】:

根据以下链接,我安装并执行了示例 CPP 程序。但我有一个错误:

https://code.visualstudio.com/docs/cpp/config-mingw

Tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

PS F:\VS_Code\projects\cpp\helloworld> helloworld.exe helloworld.exe:术语“helloworld.exe”不被识别为 cmdlet、函数、脚本文件或可运行程序的名称。 检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。 在 line:1 char:1

  • helloworld.exe
  •   + CategoryInfo          : ObjectNotFound: (helloworld.exe:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    
    

建议[3,General]:没有找到命令helloworld.exe,但在当前位置确实存在。默认情况下,Windows PowerShell 不会从当前位置加载命令。如果您信任此命令,请键入:“.\helloworld.exe”。有关详细信息,请参阅“get-help about_Command_Precedence”

【问题讨论】:

    标签: visual-studio-code


    【解决方案1】:

    我只是想知道这个!键入“.\helloworld.exe”,您将看到“HelloWorld”,因为您正在使用 PowerShell。如果您在命令提示符中,请输入“helloworld.exe”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-27
      • 2022-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多