繁体   English   中英

Eclipse CDT上的编译错误

[英]Compilation error on 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;
}

我在几天前遇到过这个问题,结果问题是我安装了g ++ 4.3和g ++ 4.4而且Eclipse感到困惑。 我卸载了4.3,问题就消失了。

暂无
暂无

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

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