2011-09-07 93 views
0

我在我的電腦上安裝了MinGW(我只使用Strawberry perl附帶的一個)。我可以從命令行編譯得很好。然而,使用Eclipse CDT會導致奇怪的錯誤。使用附帶的Eclipse的C++的Hello World默認項目,彙編CDT失敗,這些錯誤:Eclipse上的編譯錯誤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)都在我的路徑變量中。我需要更改哪些日食設置才能完成這項工作?

這裏是我想要編譯文件:

#include <iostream> 
using namespace std; 

int main() { 
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! 
    return 0; 
} 
+1

轉到您的項目屬性,導航到'C \ C++常規>路徑和符號>包含(選項卡)'並選擇'GNU C++'語言。你看到MinGW安裝的一堆路徑嗎?另外,你可以發佈你正在編譯的代碼(一個簡化版本)。最後你有一個MINGW_HOME環境變量集? –

+0

你記得'#包括'嗎? – Daniel

回答

2

我只是前幾天遇到過,這個問題竟然是,我有兩個G ++ 4.3和g ++ 4.4安裝Eclipse變得困惑。我卸載4.3並且問題消失了。