Eclipse CDT 编译错误
我的计算机上安装了 MinGW(我只使用 Strawberry Perl 附带的那个)。我可以从命令行编译东西。然而,使用 Eclipse CDT 会导致奇怪的错误。使用 Eclipse 附带的 c++ hello world 默认项目,CDT 中的编译失败并出现以下错误:
\**** Internal Builder is used for build \****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o ..\src\hw.cpp
..\src\hw.cpp:9:20: error: iostream: No such file or directory
..\src\hw.cpp: In function 'int main()':
..\src\hw.cpp:13: error: 'cout' was not declared in this scope
..\src\hw.cpp:13: error: 'endl' was not declared in this scope
Build error occurred, build is stopped
Time consumed: 263 ms.
但是当我运行 g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o .. \src\hw.cpp 在我的命令行编译运行得很好。所有正确的头文件(如 iostream)都在我的路径变量中。我需要更改哪些 Eclipse 设置才能使其正常工作?
这是我正在尝试编译的文件:
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
I have MinGW installed on my computer (I just use the one shipped with Strawberry perl). I can compile things just fine from the command line. Using Eclipse CDT, however, results in weird errors. Using the c++ hello world default project which comes with Eclipse, compilation in CDT fails with these errors:
\**** Internal Builder is used for build \****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o ..\src\hw.cpp
..\src\hw.cpp:9:20: error: iostream: No such file or directory
..\src\hw.cpp: In function 'int main()':
..\src\hw.cpp:13: error: 'cout' was not declared in this scope
..\src\hw.cpp:13: error: 'endl' was not declared in this scope
Build error occurred, build is stopped
Time consumed: 263 ms.
But when I run g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o ..\src\hw.cpp
on my command line compilation goes just fine. All of the proper header files (like iostream) are in my path variable. What eclipse settings do I need to change to make this work?
Here's the file I'm trying to compile:
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我几天前就经历过这种情况,问题是我同时安装了 g++4.3 和 g++4.4,而 Eclipse 变得混乱。我卸载了4.3,问题就消失了。
I experienced this only a few days ago, the problem turned out to be that I had both g++4.3 and g++4.4 installed and Eclipse was getting confused. I uninstalled 4.3 and the problem went away.