【问题标题】:g++ is recognized by cmd but not by vs codeg++ 被 cmd 识别,但不被 vs 代码识别
【发布时间】:2021-11-22 05:29:32
【问题描述】:

我正在尝试在我的 Visual Studio 代码中设置 c/c++ 环境。我已经安装了mingw并设置了bin文件夹的环境变量。但是在 vs code 中运行代码时,它会显示以下错误:

g++ : 术语“g++”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查拼写 名称,或者如果包含路径,请验证路径是否正确并 再试一次。在行:1 字符:40 cd "e:\vsCodes\Cpp 代码" ; if ($?) { g++ threen1.cpp -o threen1 } ; ... CategoryInfo : ObjectNotFound: (g++:String) [], CommandNotFound 异常 FullyQualifiedErrorId : CommandNotFoundException

但是当我输入g++ --version时,命令提示符会显示以下消息:

g++ (tdm64-1) 10.3.0 版权所有 (C) 2020 Free Software Foundation, Inc. 这是免费软件;查看复制条件的来源。那里 没有保证;甚至不适合适销性或适合性 特殊目的。

我已尝试按照this thread 中的答案解决问题。

【问题讨论】:

    标签: c++ visual-studio-code mingw


    【解决方案1】:

    您正在使用powershell 终端,如果您不知道powershell 是什么或者您不需要powershell,我建议您运行命令提示符终端(cmd)。它在终端菜单中可用:

    在 powershell 中,您可以验证 PATH 中的 g++ 运行此命令 echo $env:path,它等效于 echo %PATH% 的 powershell

    【讨论】:

    • 感谢您的回答!
    • @AshishNeupane 不客气
    猜你喜欢
    • 2022-01-06
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    • 2010-11-01
    • 2019-02-23
    • 1970-01-01
    • 2018-01-06
    • 1970-01-01
    相关资源
    最近更新 更多