C++ MinGW:“gcc 不被识别为内部或外部命令”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26304916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 11:34:12  来源:igfitidea点击:

MinGW: "gcc is not recognized as an internal or external command"

c++windowsgccmingw

提问by Aviv Cohn

I downloaded and installed MinGW. I used the graphical program to install the C++ compiler.

我下载并安装了 MinGW。我使用图形程序来安装 C++ 编译器。

Typing gccin the Windows command line prints:

gcc在 Windows 命令行中键入打印:

gcc is not recognized as an internal or external command

I checked, and gcc.exeis present in C:\MinGW\bin. What's wrong?

我检查过,并且gcc.exe存在于C:\MinGW\bin. 怎么了?

回答by user7943

Although an old question, none of the answers here helped me. The only route I found to get to my destination is by typing in the following line in my command prompt:

虽然是一个老问题,但这里的答案都没有帮助我。我发现到达目的地的唯一途径是在命令提示符中输入以下行:

enter image description here

在此处输入图片说明

After that, simply type in gcc -v.

之后,只需键入 gcc -v。

Hope this helps anyone with the problem I had!

希望这可以帮助任何人解决我遇到的问题!

回答by Gavin Simpson

Or at the command line you must type in "\mingw\bin\gcc" instead of just "gcc". Best to set the environment as mentioned above.

或者在命令行中,您必须输入“\mingw\bin\gcc”而不仅仅是“gcc”。最好设置上面提到的环境。

回答by user3501697

Please edit the Path variable to append a semicolon followed by location "C:\MinGW\bin" and do NOT use any spaces while doing so.

请编辑 Path 变量以附加一个分号,后跟位置“C:\MinGW\bin”,并且在执行此操作时不要使用任何空格。

回答by monkrus

Please try the following: click on "New" under Environmental Variables and add the following line to both user and system variables without editing:

请尝试以下操作:单击“环境变量”下的“新建”,并将以下行添加到用户和系统变量中,无需编辑:

C:\mingw32\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

回答by Luis Jose

maybe this is obvious, but don't forget that the PATH environment variable is case sensitive.

也许这很明显,但不要忘记 PATH 环境变量区分大小写。