C语言 编译c时使用cygwin“-bash:gcc:找不到命令”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25705726/
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
"-bash: gcc: command not found" using cygwin when compiling c?
提问by Belphegor
I just installed the latest version of Cygwin ans for some reason when I try to compile code, it always flashes me this error:
当我尝试编译代码时,出于某种原因,我刚刚安装了最新版本的 Cygwin ans,它总是向我显示此错误:
-bash: gcc: command not
-bash: gcc: 命令不是
I also don't seem to have the gcc.exe that people are referring to and when I try installing stuff like mingw as suggested by other forum answers, it always gives me this error that ti couldn't install the repository.txt.... Looking for help on this matter!
我似乎也没有人们所指的 gcc.exe,当我尝试按照其他论坛答案的建议安装 mingw 之类的东西时,它总是给我这个错误,提示我无法安装 repository.txt .. .. 在这件事上寻求帮助!
回答by David L.
You can install gcc by running setup-x86.exe or setup-x86_64.exe again. The gcc package is in the Devel category:
您可以通过再次运行 setup-x86.exe 或 setup-x86_64.exe 来安装 gcc。gcc 包在 Devel 类别中:


回答by vinniyo
Then you must go to System properties, System variables, and append the path to "C:\cygwin64\bin" in PATH
然后你必须转到系统属性,系统变量,并将路径附加到 PATH 中的“C:\cygwin64\bin”
回答by Manohar Reddy Poreddy
Related issue.
相关问题。
I received below error:
我收到以下错误:
'g++' is not recognized as an internal or external command,
'g++' 不被识别为内部或外部命令,
Did the below to resolve:
做了以下解决:
- Downloaded & installed setup-x86_64.exe from https://cygwin.com/install.html
selected below:
gcc-g++: GNU Compiler Collection (C++)
make: The GNU version of the 'make' utility
gdb: The GNU DebuggerAppended ';C:\cygwin64\bin' to PATH environment variable
- 从https://cygwin.com/install.html下载并安装 setup-x86_64.exe
以下选择:
gcc-g++:GNU 编译器集合 (C++)
make:'make' 实用程序的 GNU 版本
gdb:GNU 调试器将 ';C:\cygwin64\bin' 附加到 PATH 环境变量
All errors are gone.
所有错误都消失了。
回答by Eman
If you have already added the gcc package you want you may also need to setup a symbolic link to a different gcc.exe binary. For example:
如果您已经添加了您想要的 gcc 包,您可能还需要设置一个指向不同 gcc.exe 二进制文件的符号链接。例如:
$cd /usr/bin/
$ln -s i686-pc-cygwin-gcc.exe gcc
$which gcc
$/usr/bin/gcc
You can add the gcc package through the 'Add Package' batch file.
您可以通过“添加包”批处理文件添加 gcc 包。
回答by vicky sable
when selecting packages at installation or update search for 'gcc' in searchbox and select the boxes showing 'gcc' mostly found in devel package.
在安装或更新时选择软件包时,在搜索框中搜索“gcc”并选择显示“gcc”的框,这些框主要在 devel 软件包中找到。
回答by PARTH SURESH
Try installing cygwin from a mirror you did not use earlier(preferably the first one). Some of the servers hold older versions of cygwin which have many problems. Also, search for gcc and install the devel package.
尝试从您之前没有使用过的镜像(最好是第一个)安装 cygwin。一些服务器拥有旧版本的 cygwin,它们有很多问题。另外,搜索 gcc 并安装 devel 包。
I had the same problem when I installed cygwin from the iitm mirror(closest to my home), and it got resolved when I reinstalled the whole thing from the cygwin mirror.
当我从 iitm 镜像(离我家最近)安装 cygwin 时遇到了同样的问题,当我从 cygwin 镜像重新安装整个东西时它得到了解决。

