C语言 CodeBlocks 中的“没有这样的文件或目录”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17377964/
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-09-02 06:50:12  来源:igfitidea点击:

"No such file or directory" error in CodeBlocks

ccodeblocks

提问by Zeta.Investigator

Here is the steps I followed in CodeBlocks IDE:

这是我在 CodeBlocks IDE 中遵循的步骤:

Create a new project->console->C->Name->debug and release->finish

So when I choose main.cand build it, It should show the "Hello World!", but I get this weird mingw32-gcc.exe: error: CreateProcess: No such file or directoryerror.

所以当我选择main.c并构建它时,它应该显示“Hello World!”,但我收到了这个奇怪的mingw32-gcc.exe: error: CreateProcess: No such file or directory错误。

I've written and compiled about 20 C files this way, but I don't know what has recently happened to the IDE.

我已经用这种方式编写和编译了大约 20 个 C 文件,但我不知道 IDE 最近发生了什么。

I've checked the CodeBlocks forum and googled this problem;No results
Any ideas?

我检查了 CodeBlocks 论坛并用谷歌搜索了这个问题;没有结果 有
什么想法吗?

Bulid Log:

建立日志:

-------------- Build: Debug in C (compiler: GNU GCC Compiler)---------------

mingw32-gcc.exe -Wall  -g     -c "C:...\Project Files\C Codes\C\main.c" -o obj\Debug\main.o
mingw32-gcc.exe: error: CreateProcess: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)

I used CodeBlocks 10.02 three days ago and it compiled and ran the code successfully. It showed this error yesterday. I thought that maybe the code file wasn't included so I removed the previous code from the project and added the new file (I do like this for about 20 programs and always get results); but the error still exists. Then I rebuilt the project but still got the error. I uninstalled ver.10.02 and installed a new version 12.11 today. Again I get this weird error.

我三天前使用了 CodeBlocks 10.02,它成功编译并运行了代码。昨天显示这个错误。我想可能没有包含代码文件,所以我从项目中删除了以前的代码并添加了新文件(我喜欢这个大约 20 个程序并且总是得到结果);但错误仍然存​​在。然后我重建了项目,但仍然出现错误。我今天卸载了 ver.10.02 并安装了新版本 12.11。我再次收到这个奇怪的错误。

P.S. It looks like someone else have had this problem too:
mingw32-g++.exe: error: CreateProcess: No such file or directory

PS 看起来其他人也有这个问题:
mingw32-g++.exe: error: CreateProcess: No such file or directory

采纳答案by Zeta.Investigator

Got it finally:

终于明白了:

In my case, the problem resulted from a program called EGCS (Experimental/Enhanced GNU Compiler System). I installed it as a prerequisite for PSCAD(Power Systems CAD) along with a FORTRAN Compiler. Just remove it, and you'll be fine.
(Sadly, I deleted the entire PATH environmental variable due to a mistake. So what?...I ended up installing a new Win7 but after uninstalling my Ubuntu which again due to the Boot difficulties which resulted from uninstalling GRUB, I again ended up messing around with fixmbr and fixboot fellas(But I've lost my Laptop DVD!)...In summary, The EGCS laughed at me for a 0.5*MONTH...)

就我而言,问题是由一个名为EGCS (Experimental/Enhanced GNU Compiler System) 的程序引起的。我将它安装为 PSCAD(Power Systems CAD)和 FORTRAN 编译器的先决条件。把它去掉,你会没事的。
(遗憾的是,由于错误,我删除了整个 PATH 环境变量。那又怎样?...我最终安装了一个新的 Win7,但在卸载我的 Ubuntu 之后,由于卸载 GRUB 导致启动困难,我再次结束了搞乱 fixmbr 和 fixboot 家伙(但我丢失了我的笔记本电脑 DVD!)......总而言之,EGCS 嘲笑我 0.5*MONTH......)

For more information about such problems visit here(Code::Blocks Forum)

有关此类问题的更多信息,请访问此处(代码::块论坛)

回答by greatwolf

Codeblocks seems to be calling gcc correct -- I'm not seeing anything wrong with the way it's being invoked. The error message you're getting:

Codeblocks 似乎正确地调用了 gcc——我没有发现它被调用的方式有什么问题。您收到的错误消息:

gcc.exe: error: CreateProcess: No such file or directory

gcc.exe:错误:CreateProcess:没有那个文件或目录

indicates that there is something wrong with your installation of mingw-gcc. Since you said that this was working previously, that likely means some files required for gcc to function are either corrupted, inadvertently renamed, moved elsewhere or accidentally deleted.

表示您安装的 mingw-gcc 有问题。由于您之前说过这有效,这可能意味着 gcc 运行所需的某些文件已损坏、无意中重命名、移动到其他地方或意外删除。

In fact, I was able to reproduce that exact error by renaming cc1.exe. This is the C compiler that gcc needs to able to compile a C source file. On my install for Mingw-4.6.3, this resides under ./libexec/gcc/i686-w64-mingw32/4.6.3. Yours may be different depending on which mingw version and variant you're using.

事实上,我能够通过重命名cc1.exe. 这是 gcc 需要能够编译 C 源文件的 C 编译器。在我安装 Mingw-4.6.3 时,它位于./libexec/gcc/i686-w64-mingw32/4.6.3. 根据您使用的 mingw 版本和变体,您的可能会有所不同。

I recommend downloading and reinstalling your copy of gcc altogether since fixing this manually can be tricky.

我建议完全下载并重新安装您的 gcc 副本,因为手动修复此问题可能很棘手。

回答by codesavory

The answers here failed to solve my problem! My friend got it fixed for me. The solution was pretty simple and straight forward. The problem that occurred was that compiler couldn't chain itself with the MinGW (Minimalist GNU for Windows) which could have been modified by some other make files for makefiles softwares like CMake etc. So the solution is:

这里的答案未能解决我的问题!我朋友帮我修好了。解决方案非常简单直接。发生的问题是编译器无法将自己与 MinGW(Windows 的 Minimalist GNU)链接起来,而 MinGW(Windows 的 Minimalist GNU)可能已被其他一些 makefiles 软件(如 CMake 等)的 make 文件修改。所以解决方案是:

  1. Open Codeblocks and in the top Tool Bar select the Settings option and under that select the compiler option.
  2. It will open the Compiler Setting Window. Here select the Global Compiler settings(with a Gear Symbol) and in the sub-options select the Toolchain executables option.
  3. Under this select the Compiler's installation directory. Here browse files to select: C:\Program Files(x86)\Codeblocks\MinGW\bin
  4. Now select the Auto-detect option on the right.
  1. 打开 Codeblocks 并在顶部工具栏中选择设置选项,然后在该选项下选择编译器选项。
  2. 它将打开编译器设置窗口。在这里选择全局编译器设置(带有齿轮符号)并在子选项中选择工具链可执行文件选项。
  3. 在此选择编译器的安装目录。这里浏览文件选择:C:\Program Files(x86)\Codeblocks\MinGW\bin
  4. 现在选择右侧的自动检测选项。

It should solve your problem and I hope you got an understanding of what the problem was!!! Happy Programming!

它应该可以解决您的问题,我希望您了解问题所在!!!编程快乐!

回答by mendel

After two days of struggle, I confirmed the solution from codesavory and Anand MP.

经过两天的挣扎,我确认了codesavory和Anand MP的解决方案。

All the reason is the Toolchain Executables. I finally found that it was cygwin's path!

所有的原因都是工具链可执行文件。终于发现是cygwin的路径了!

After I change to D:\GreenSoft\CodeBlocks\MinGW, it compiles ok now!

在我更改为 D:\GreenSoft\CodeBlocks\MinGW 后,它现在可以编译了!

I think the problem take place at the install step: codeblocks detect everywhere on your PC to find a existing gcc, and let you choose one as your favorite. It even forgot that the installer is already bundled with a minGW!, and it does not show where the detected gcc are located! So if you simply confirm one and forget it, it will abandon the bundled minGW.

我认为问题发生在安装步骤:代码块检测您 PC 上的任何地方以查找现有的 gcc,并让您选择一个作为您最喜欢的。它甚至忘记了安装程序已经捆绑了一个minGW!,并且它没有显示检测到的gcc所在的位置!所以如果你简单的确认一个忘记了,它就会放弃捆绑的minGW。

回答by user13380573

Open command line and type in:

打开命令行并输入:

mingw-get update && mingw-get install mingw32-gcc

This will download the missing GCC files.

这将下载丢失的 GCC 文件。

回答by Surya Pranav

I just solved this error. Probably I got this when I moved a file accidentally which was under execution in C-Free IDE. All you have to do is ,locate the g++.exe file in your Program files. Just go through the program files of the particular IDE and find mingW folder and locate the 'g++.exe' inside it.

我刚刚解决了这个错误。可能是我意外移动了一个正在 C-Free IDE 中执行的文件时得到了这个。您所要做的就是在您的程序文件中找到 g++.exe 文件。只需浏览特定 IDE 的程序文件并找到 mingW 文件夹并找到其中的“g++.exe”。

回答by Anand MP

This usually happens when the compilers PATH in Codeblocks is not a valid one. In my case it was pointing to C:/MinGW. Which Codeblocks found out using its auto detect feature.

这通常发生在 Codeblocks 中的编译器 PATH 无效时。就我而言,它指向 C:/MinGW。哪些代码块使用其自动检测功能发现。

To get rid of the error you need to change the path back to the one that is present within the Codeblocks program folder.

要消除错误,您需要将路径更改回 Codeblocks 程序文件夹中的路径。

In my case it was - C:\Program Files (x86)\CodeBlocks\MinGW.

就我而言,它是 - C:\Program Files (x86)\CodeBlocks\MinGW。

You can change the path in Codeblocks by following these steps. Menu bar-> Settings-> Compiler-> Toolchain Executables. Then enter the corresponding valid compiler directory path.

您可以按照以下步骤更改 Codeblocks 中的路径。菜单栏-> 设置-> 编译器-> 工具链可执行文件。然后输入对应的有效编译器目录路径。

Hope this solves your problem.

希望这能解决您的问题。

回答by newbie

I still had a problem with that error. Turns out it was there beacause I had MinGW installed externally before installing CodeBlocks.

我仍然遇到那个错误的问题。原来是因为我在安装 CodeBlocks 之前在外部安装了 MinGW。

In that case check if your directory path (explained how to change it above) isn't C:\MinGW\binbut instead C:\Program Files (x86)\CodeBlocks\MinGW\binsince it may cause the error to pop up.

在这种情况下,检查您的目录路径(上面解释了如何更改它)不是C:\MinGW\bin而是C:\Program Files (x86)\CodeBlocks\MinGW\bin因为它可能导致错误弹出。