简体   繁体   English

Eclipse CDT上的编译错误

[英]Compilation error on Eclipse CDT

I have MinGW installed on my computer (I just use the one shipped with Strawberry perl). 我在我的电脑上安装了MinGW(我只使用Strawberry perl附带的一个)。 I can compile things just fine from the command line. 我可以从命令行编译好的东西。 Using Eclipse CDT, however, results in weird errors. 但是,使用Eclipse CDT会导致奇怪的错误。 Using the c++ hello world default project which comes with Eclipse, compilation in CDT fails with these errors: 使用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.  

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. 但是当我在命令行上运行g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\\hw.o ..\\src\\hw.cpp ,编译就可以了。 All of the proper header files (like iostream) are in my path variable. 所有正确的头文件(如iostream)都在我的路径变量中。 What eclipse settings do I need to change to make this work? 我需要更改哪些eclipse设置才能使其工作?

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;
}

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. 我在几天前遇到过这个问题,结果问题是我安装了g ++ 4.3和g ++ 4.4而且Eclipse感到困惑。 I uninstalled 4.3 and the problem went away. 我卸载了4.3,问题就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM