Eclipse CDT错误:无法编译

发布于 2024-11-04 20:36:21 字数 1764 浏览 0 评论 0原文

我尝试运行一个简单的 Hello world 程序。当我尝试构建它时,我收到此错误。这是什么意思以及如何解决?我使用的是 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.  

代码:

#include <iostream>

int main()
{
    std::cout << "Hello, world!" << std::endl;
    return 0;
}

我的 %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

我能够从 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 tried to run a simple Hello world program. 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%.

**** 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:

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:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

厌味 2024-11-11 20:36:21

我在调用 MinGW gcc 编译器的 C HelloWorld 中发现了同样的问题。经过相当多的实验,我发现 MinGW binutils 包是罪魁祸首!由于某种原因,最新的一个与 CDT 不能很好地配合。使用这个,它会起作用:)

binutils-2.21-2-mingw32-bin.tar.lzma

注意: 2.21-3 及更高版本似乎有问题。

此外,最新的 GDB 7.3 似乎也挂起。使用这个:

gdb-7.2-1-mingw32-bin.tar.lzma

快乐编码:)

PS:我什至没有 MinGW 或 MSYS 小路。只要 MinGW 位于 C:\MinGW 中,事情就会神奇地工作。

I found the same problem with a C HelloWorld invoking the MinGW gcc compiler. After quite a bit of experimentation, I have found that the MinGW binutils package is to blame! The latest one doesn't play nice with CDT for some reason. Use this one instead and it will work :)

binutils-2.21-2-mingw32-bin.tar.lzma

NOTE: versions 2.21-3 and later seem to have the problem.

Additionally, the latest GDB 7.3 seems to hang too. Use this one:

gdb-7.2-1-mingw32-bin.tar.lzma

Happy coding :)

PS: I don't even have MinGW or MSYS in the path. As long as MinGW is in C:\MinGW things seem to magically work.

肤浅与狂妄 2024-11-11 20:36:21

设置环境后尝试重新启动系统。请参考这里:

CreateProcess:没有这样的文件或目录

Try rebooting your system after setting your environment. Please refer to here:

CreateProcess: No such file or directory

月下凄凉 2024-11-11 20:36:21

您是如何创建该项目的?从新建->C++ 项目开始。然后在可执行文件下选择“Hello World C++ Project”。在工具链上,我选择了 MinGW GCC 工具链,但您可能没有安装它。无论如何,这创建了一个完全可编译的可执行文件,为学习提供了一个良好的起点。它将所有包含目录、库路径等放入项目设置中。

How did you create the project? Start with the New->C++ Project. Then under Executable pick the "Hello World C++ Project". On the Toolchains I pick the MinGW GCC toolchain but it's possible you don't have that installed. 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.

深海蓝天 2024-11-11 20:36:21

我有类似的问题。
只需从 PATH 中删除“C:\MinGW\bin”,重新安装 MinGW 就可以了。 Ecllipse 或 CLion 不需要设置 PATH。 CLion 甚至警告“C:\MinGW\bin”不应位于 PATH 中。

I had similiar problem.
Just deleted "C:\MinGW\bin" from the PATH, reinstalled MinGW and it worked. Ecllipse or CLion don't need PATH to be set. CLion even warns that "C:\MinGW\bin" should not be in the PATH.

东京女 2024-11-11 20:36:21

我用了一个技巧。
我已经安装了 Dev-Cpp,并在其中安装了 Mingw32。
我将 Mingw32 复制到目录 c: 并将 mingw32 重命名为 c:\MinGW
并包含到%PATH%。效果非常好。

I used an artifice.
I have installed the Dev-Cpp and within it comes installed Mingw32.
I copied the Mingw32 to directory c: and rename the mingw32 to c:\MinGW
and include to %PATH%. It worked very well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文