2010-04-25 99 views
2

我正在使用cygwin庫在Windows上運行C和C++程序。g ++沒有正確鏈接頭文件

gcc運行正常,但與g++,我收到一長串的錯誤。我認爲這些錯誤是因爲與C庫鏈接問題。

你能建議我需要做什麼來解決這個問題嗎?


開始錯誤行:

In file included from testgpp.cpp:1: 
/cygdrive/c/cygwin/bin/../lib/gcc/i686-pc-cygwin/3.4.4/include/c++/cstdio:52:19: stdio.h: No such file or directory 
In file included from testgpp.cpp:1: 
/cygdrive/c/cygwin/bin/../lib/gcc/i686-pc-cygwin/3.4.4/include/c++/cstdio:99: error: `::FILE' has not been declared 
/cygdrive/c/cygwin/bin/../lib/gcc/i686-pc-cygwin/3.4.4/include/c++/cstdio:100: error: `::fpos_t' has not been declared 
/cygdrive/c/cygwin/bin/../lib/gcc/i686-pc-cygwin/3.4.4/include/c++/cstdio:102: error: `::clearerr' has not been declared 
/cygdrive/c/cygwin/bin/../lib/gcc/i686-pc-cygwin/3.4.4/include/c++/cstdio:103: error: `::fclose' has not been declared 
/cygdrive/c/cygwin/bin/../lib/gcc/i686-pc-cygwin/3.4.4/include/c++/cstdio:104: error: `::feof' has not been declared 

整個錯誤轉儲: PasteBin


人們要求的源代碼:這這顯然是一個頭文件鏈接並且在編譯開始之前發生。每個.cpp文件都會得到相同的錯誤。

#include<cstdio> 
#include<cstdlib> 
#include<iostream> 
#include<vector> 
#include<queue> 
using namespace std; 

int main(){ 
    cout<<"hello world!";  
} 

給了我一個非常相同的錯誤。

+0

什麼是命令行? – 2010-04-25 05:59:09

+0

@Marcelo Cantos:'g ++ testgpp.cpp' – Moeb 2010-04-25 06:04:34

+0

沒有看到更多的細節,我不能給你一個答案,但如果你包含「windows.h」......已知與Cygwin的交互性很差,並且可能會有時會導致與上述類似的錯誤。 – 2010-04-25 06:05:49

回答

1

關鍵的錯誤是:

In file included from testgpp.cpp:1: 
[...]/include/c++/cstdio:52:19: stdio.h: No such file or directory 

是G ++抱怨它不能找到<stdio.h>(雖然它的葉子尖括號從消息中),這意味着你有某種形式的編譯器配置問題。可能,你錯過了一個關鍵的軟件包。我希望重新安裝或更新您的GCC環境,以便找到<stdio.h>

其餘的問題是缺少標題的後果 - 編譯器正在努力工作,沒有它所需的所有信息來避免產生不必要的錯誤。