C语言 CreateProcess:没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3848357/
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
CreateProcess: No such file or directory
提问by Insomaniacal
I am getting this error whenever I try to run GCC outside of its installation directory (E:\MinGW\bin).
每当我尝试在其安装目录 ( E:\MinGW\bin)之外运行 GCC 时,我都会收到此错误。
So, let's say I am in E:\codeand have a file called one.c. Running:
gcc one.c -o one.exewill give me this error:
所以,假设我在里面E:\code并有一个名为one.c. 运行:
gcc one.c -o one.exe会给我这个错误:
gcc: CreateProcess: No such file or directory
The only workaround is to navigate to its installation directory, run gcc from there, and specify all the other paths. My environmental variable Pathcontains E:\MinGW\bin.
唯一的解决方法是导航到其安装目录,从那里运行 gcc,并指定所有其他路径。我的环境变量Path包含E:\MinGW\bin.
Any suggestions to fixing this problem? I am running Windows XP SP3.
有什么建议可以解决这个问题吗?我正在运行 Windows XP SP3。
采纳答案by Vadzim
Its specifically told that you need to reboot after you set the environmental variables in windows for migwin.
它特别告诉您在Windows中为migwin设置环境变量后需要重新启动。
回答by Herberth Amaral
According to Code::Blocks wiki, you need to add C:\MinGW\libexec\gcc\mingw32\MinGW-Versionto your PATH. There is no need to restart, but you need to open another terminal in order to get the newest PATHsettings.
据代码:: Blocks的维基,你需要添加C:\MinGW\libexec\gcc\mingw32\MinGW-Version到您的PATH。无需重新启动,但您需要打开另一个终端才能获得最新PATH设置。
For MinGW-w64, that's <mingw install directory>\libexec\gcc\x86_64-w64-mingw32\4.7.0\
对于 MinGW-w64,那就是 <mingw install directory>\libexec\gcc\x86_64-w64-mingw32\4.7.0\
回答by Luis Bruno
I had a similar problem, caused by not installing the C++ compiler. In my case I was compiling .cpp files for a Python extension, but the compiler is first invoked as c:\mingw\bin\gcc.exe.
我有一个类似的问题,因为没有安装 C++ 编译器。在我的例子中,我正在为 Python 扩展编译 .cpp 文件,但编译器首先被调用为 c:\mingw\bin\gcc.exe。
Internally, gcc.exe would notice it was asked to compile a .cpp file. It would try to call g++.exe and fail with the same error message:
在内部,gcc.exe 会注意到它被要求编译一个 .cpp 文件。它会尝试调用 g++.exe 并失败并显示相同的错误消息:
gcc.exe: CreateProcess: no such file or directory
gcc.exe: CreateProcess: 没有那个文件或目录
回答by Pedro Henrique A. Oliveira
I just had this problem.
我刚遇到这个问题。
In my case, the problem was due to problems when downloading the packages for GCC. The mingw-get program thought it finished the download, but it didn't.
就我而言,问题是由于下载 GCC 软件包时出现问题。mingw-get 程序认为它完成了下载,但它没有。
I wanted to upgrade GCC, so I used mingw-get to get the newer version. For some reason, mingw-get thought the download for a particular file was finished, but it wasn't. When it went to extract the file, I guess it issued an error (which I didn't even bother to look -- I just ran "mingw-get update && mingw-get install mingw32-gcc" and left it there).
我想升级 GCC,所以我使用 mingw-get 来获取更新的版本。出于某种原因,mingw-get 认为特定文件的下载已完成,但事实并非如此。当它提取文件时,我猜它发出了一个错误(我什至懒得看——我只是运行了“mingw-get update && mingw-get install mingw32-gcc”并将其留在那里)。
To solve, I removed gcc by doing "mingw-get remove mingw32-gcc" and also removed the package file (the one mingw-get didn't fully download), which was in the mingw cache folder ("C:\MinGW\var\cache\mingw-get\packages" in my system), then ran the install command again. It download and installed the missing parts of GCC (it had not fully downloaded the package gcc-core).
为了解决这个问题,我通过执行“mingw-get remove mingw32-gcc”删除了gcc,并删除了包文件(一个mingw-get没有完全下载),它位于mingw缓存文件夹(“C:\MinGW\ var\cache\mingw-get\packages" 在我的系统中),然后再次运行安装命令。它下载并安装了 GCC 的缺失部分(它还没有完全下载包 gcc-core)。
That solved my problem.
那解决了我的问题。
Interestingly enough, mingw-get was smart enough to continue the download of gcc-core even after me having deleted the package file in the cache folder, and also removed the package mingw32-gcc.
有趣的是,即使我删除了缓存文件夹中的包文件,mingw-get 也足够聪明,可以继续下载 gcc-core,并且还删除了包 mingw32-gcc。
I think the more fundamental problem was that since gcc-core files were not installed, cc1 wasn't there. And gcc uses cc1. I guess that, when gcc tried to start cc1, it used CreateProcess somewhere passing the path of cc1, which was not the path of an existing file. Thus the error message.
我认为更根本的问题是因为没有安装 gcc-core 文件,所以 cc1 不存在。而 gcc 使用 cc1。我猜想,当 gcc 尝试启动 cc1 时,它在某处使用 CreateProcess 传递 cc1 的路径,这不是现有文件的路径。因此错误信息。
回答by Colonel Panic
So this is a stupid error message because it doesn't tell you whatfile it can't find.
所以这是一个愚蠢的错误消息,因为它没有告诉你它找不到什么文件。
Run the command again with the verbose flag gcc -vto see what gcc is up to.
使用详细标志再次运行命令gcc -v以查看 gcc 正在做什么。
In my case, it happened it was trying to call cc1plus. I checked, I don't have that. Installed mingw's C++ compiler and then I did.
就我而言,碰巧它试图调用cc1plus. 我查过,我没有。安装了 mingw 的 C++ 编译器,然后我做了。
回答by znatz
I had exactly the same problem.
我遇到了完全相同的问题。
After a recheck of my PATH, I realized I installed both Mingw(64 bit) and Cygwin(32 bit).
The problem is that both Mingwand Cygwinhave g++.
重新检查我的 . 后PATH,我意识到我安装了Mingw(64 位)和Cygwin(32 位)。问题是Mingw和Cygwin都有g++。
By deactivating the path of Cygwin, the error disappeared.
通过停用 的路径Cygwin,错误消失了。
回答by Lyle
I had this same problem and none of the suggested fixes worked for me. So even though this is an old thread, I figure I might as well post my solution in case someone else finds this thread through Google(like I did).
我遇到了同样的问题,建议的修复方法都不适合我。所以即使这是一个旧线程,我想我也可以发布我的解决方案,以防其他人通过谷歌找到这个线程(就像我一样)。
For me, I had to uninstall MinGW/delete the MinGW folder, and re-install. After re-installing it works like a charm.
对我来说,我不得不卸载 MinGW/删除 MinGW 文件夹,然后重新安装。重新安装后,它就像一个魅力。
回答by iulian
Was getting the same error message when trying to run from Cygwin with links to the mingw install.
尝试从带有 mingw 安装链接的 Cygwin 运行时收到相同的错误消息。
Using the same install of mingw32-make-3.80.0-3.exe from http://www.mingw.org/wiki/FAQand the mingw shell option from Start -> Programs -> on a WinXP SP3 and gcc is working fine.
使用来自http://www.mingw.org/wiki/FAQ的相同 mingw32-make-3.80.0-3.exe 安装和来自开始 -> 程序 -> 在 WinXP SP3 上的 mingw shell 选项,gcc 正在工作美好的。
回答by Technophile
In the "give a man a fish, feed him for a day; teach a man to fish, get rid of him for the whole weekend" vein,
在“授人以鱼,养他一日;授人以渔,除他一整个周末”的脉络中,
g++ --help显示编译器选项。g++ -v 选项有助于:
-v Display the programs invoked by the compiler
Look through the output for bogus paths. In my case the original command:
查看输出是否有虚假路径。在我的情况下,原始命令:
g++ -v "d:/UW_Work/EasyUnit/examples/1-BasicUnitTesting/main.cpp"
generated output including this little gem:
生成的输出包括这个小宝石:
-iprefix c:\olimexods\yagarto\arm-none-eabi\bin\../lib/gcc/arm-none-eabi/4.5.1/
which would explain the "no such file or directory" message.
这将解释“没有这样的文件或目录”消息。
The "../lib/gcc/arm-none-eabi/4.5.1/" segment is coming from built-in specs:
“../lib/gcc/arm-none-eabi/4.5.1/”段来自内置规范:
g++ -dumpspecs
回答by barlop
I had a very long path, and there's a file in there somewhere (not gcc.exe) but another file, that gcc.exe is accessing from the path..
我有一条很长的路径,在某处有一个文件(不是 gcc.exe),而是另一个文件,即 gcc.exe 正在从路径访问..
So when I cleared the path, it worked
所以当我清除路径时,它起作用了
C:\MinGW>cd bin
C:\MinGW\bin>where gcc.exe
C:\MinGW\bin\gcc.exe
C:\Perl64\site\bin\gcc.exe
^^ So running gcc from there will definitely run the ming gcc.exe
^^ 所以从那里运行 gcc 肯定会运行 ming gcc.exe
C:\MinGW\bin>type file6.c
#include<stdio.h>
void main()
{
int num1,num2;
scanf("%2d %4d",&num1,&num2);
printf("a=%d b=%d",num1,num2);
scanf("%d",&num1);
//flushall();
printf("c=%d",num1);
}
Compiling it I got this error
编译它我得到这个错误
C:\MinGW\bin>gcc file6.c
gcc: error: CreateProcess: No such file or directory
My PATH was huge
我的 PATH 很大
C:\MinGW\bin>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem;C:\P......
C:\MinGW\bin>path | grep -io "ming"
C:\MinGW\bin>路径 | grep -io "明"
It didn't have ming there.
那里没有明。
C:\MinGW\bin>echo MING | grep -io "ming" MING
C:\MinGW\bin>echo MING | grep -io "ming" 明
(and yeah that grep works..the path didn't have ming there)
(是的,grep 有效……路径中没有 ming)
Clearing my path completely, led it to work!
彻底清除我的道路,让它开始工作!
C:\MinGW\bin>set PATH=
C:\MinGW\bin>gcc file6.c
C:\MinGW\bin>
So, it's not clear yet precisely what it was in the PATH that led to the clash. What directory, what file.
因此,目前尚不清楚导致冲突的路径中究竟是什么。什么目录,什么文件。
Update-
更新-
The above seems to be correct to me but to add, it's also not a simple case of something earlier in the path clashing.. because normally the current directory takes precedence. And it does here in so far as gcc --version shows it's running the ming one and not one of the ones in a conflicting directory. So there's something funny going on that, if the conflicting directory is in the path) , one has to either do .\gcc or add .to the start of the path or add c:\MinGW\binbefore any conflicting directories in the path. this is the case even when you're in C:\MinGW\binand that's strange. And when it gives an error, it is still running Ming's gcc but (For some reason) looking at the conflicting directory too, as I see from process monitor. There may be more of an answer here http://wiki.codeblocks.org/index.php?title=Installing_MinGW_with_Vistain the link mentioned in the very upvoted answer here
以上对我来说似乎是正确的,但要补充的是,这也不是路径冲突中较早的事情的简单情况..因为通常当前目录优先。只要 gcc --version 显示它正在运行 ming 一个而不是冲突目录中的一个,它就在这里。因此,发生了一些有趣的事情,如果冲突目录在路径中),则必须执行 .\gcc 或添加.到路径的开头或在路径中的c:\MinGW\bin任何冲突目录之前添加。即使你在里面也是这种情况C:\MinGW\bin,这很奇怪。当它出现错误时,它仍在运行 Ming 的 gcc,但(出于某种原因)也在查看冲突目录,正如我从进程监视器中看到的那样。这里可能有更多答案http://wiki.codeblocks.org/index.php?title=Installing_MinGW_with_Vista在非常赞成的答案中提到的链接中
That's Ming32 bit..
那是Ming32位..
Looking at Ming 64bit, probably has te same issue, but I see, interestingly, it comes with a bat file that (sensibly) actually puts the bin directory at the tart of the path. And it looks like that is a standard way of running Ming gcc properly.
看看 Ming 64bit,可能有同样的问题,但我看到,有趣的是,它附带了一个 bat 文件,它(明智地)实际上将 bin 目录放在路径的 tart 中。看起来这是正确运行 Ming gcc 的标准方式。
The code::blocks IDE (sensibly) also puts the bin directory at the start of the path. If you run a C program that shows environment variables then you see that.
code::blocks IDE(明智地)还将 bin 目录放在路径的开头。如果您运行一个显示环境变量的 C 程序,那么您会看到。
回答by tess
This problem is because you use uppercase suffix stuff.Crather than lowercase stuff.c when you compile it with Mingw GCC. For example, when you do like this:
这个问题是因为你用Mingw GCC编译时使用了大写后缀stuff.C而不是小写stuff.c。例如,当您这样做时:
gcc -o stuff stuff.C
then you will get the message: gcc: CreateProcess: No such file or directory
然后你会得到消息: gcc: CreateProcess: No such file or directory
But if you do this:
但如果你这样做:
gcc -o stuff stuff.c
then it works. I just don't know why.
那么它的工作原理。我只是不知道为什么。

