[英]Eclipse CDT error: Unable to compile
I tried to run a simple Hello world program.我试图运行一个简单的 Hello world 程序。 I am getting this error when I try to build it.
当我尝试构建它时出现此错误。 What does it mean and how do I resolve it?
这是什么意思,我该如何解决? I am using Windows 7 and I have MinGW and MSys in the %PATH%.
我正在使用 Windows 7,并且在 %PATH% 中有 MinGW 和 MSys。
**** Build of configuration Debug for project learn ****
**** Internal Builder is used for build ****
g++ -IC:\MinGW\lib\gcc\mingw32\4.5.2\include\c++ -IC:\MinGW\libexec\gcc\mingw32\4.5.2 -O0 -g3 -Wall -c -fmessage-length=0 -osrc\learn.o ..\src\learn.cpp
g++: CreateProcess: No such file or directory
Build error occurred, build is stopped
Time consumed: 78 ms.
Code:代码:
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
My %PATH% is:我的 %PATH% 是:
C:\Users\Hari>echo %PATH%
C:\Program Files (x86)\MiKTeX 2.8\miktex\bin;C:\sml\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program Files (x86)\QuickTime\QTSystem\;G:\svn\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\SlikSvn\bin\;C:\cygwin\bin\;C:\Program Files\apache-maven-2.2.1\bin\;C:\PsTools;C:\MinGW\msys\1.0\bin;C:\MinGW\bin
I am able to run g++ from cmd:我能够从 cmd 运行 g++:
C:\Users\Hari>g++ --version
g++ (GCC) 4.4.3
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I found the same problem with a C HelloWorld invoking the MinGW gcc compiler.我在调用 MinGW gcc 编译器的 C HelloWorld 中发现了同样的问题。 After quite a bit of experimentation, I have found that the MinGW binutils package is to blame.
经过相当多的实验,我发现 MinGW binutils package 是罪魁祸首。 The latest one doesn't play nice with CDT for some reason: Use this one instead and it will work :)
由于某种原因,最新的一个与 CDT 不兼容:改用这个,它会起作用 :)
binutils-2.21-2-mingw32-bin.tar.lzma binutils-2.21-2-mingw32-bin.tar.lzma
NOTE: versions 2.21-3 and later seem to have the problem.注意:2.21-3 及更高版本似乎有问题。
Additionally, the latest GDB 7.3 seems to hang too.此外,最新的 GDB 7.3 似乎也挂了。 Use this one:
使用这个:
gdb-7.2-1-mingw32-bin.tar.lzma gdb-7.2-1-mingw32-bin.tar.lzma
Happy coding:)快乐编码:)
PS: I don't even have MinGW or MSYS in the path. PS:我什至没有 MinGW 或 MSYS 在路径中。 As long as MinGW is in C:\MinGW things seem to magically work.
只要 MinGW 在 C:\MinGW 中,事情似乎就神奇地起作用了。
I had similiar problem.我有类似的问题。 Just deleted "C:\MinGW\bin" from the PATH, reinstalled MinGW and it worked.
刚刚从 PATH 中删除了“C:\MinGW\bin”,重新安装了 MinGW,它就可以工作了。 Ecllipse or CLion don't need PATH to be set.
Ecllipse 或 CLion 不需要设置 PATH。 CLion even warns that "C:\MinGW\bin" should not be in the PATH.
CLion 甚至警告说“C:\MinGW\bin”不应该在 PATH 中。
I used an artifice.我用了一个技巧。 I have installed the Dev-Cpp and within it comes installed Mingw32.
我已经安装了 Dev-Cpp 并在其中安装了 Mingw32。 I copied the Mingw32 to directory c: and rename the mingw32 to c:\MinGW and include to %PATH%.
我将 Mingw32 复制到目录 c: 并将 mingw32 重命名为 c:\MinGW 并包含到 %PATH%。 It worked very well.
它工作得很好。
Try rebooting your system after setting your environment.设置环境后尝试重新启动系统。 Please refer to here:
请参考这里:
CreateProcess: No such file or directory CreateProcess:没有这样的文件或目录
How did you create the project?你是如何创建这个项目的? Start with the New->C++ Project.
从 New->C++ 项目开始。 Then under Executable pick the "Hello World C++ Project".
然后在 Executable 下选择“Hello World C++ Project”。 On the Toolchains I pick the MinGW GCC toolchain but it's possible you don't have that installed.
在工具链上,我选择了 MinGW GCC 工具链,但您可能没有安装该工具链。 At any rate this creats a fully compilable executable that makes a good starting point for learning.
无论如何,这会创建一个完全可编译的可执行文件,它是学习的良好起点。 It puts all the include directories, library paths etc in the project settings.
它将所有包含目录、库路径等放在项目设置中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.