2010-04-25 101 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>

其余的问题是缺少标题的后果 - 编译器正在努力工作,没有它所需的所有信息来避免产生不必要的错误。