g ++没有正确链接头文件

时间:2010-04-25 05:55:35

标签: gcc cygwin g++ linker

我正在使用cygwin库在Windows上运行C和C ++程序。

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

给了我同样的错误。

1 个答案:

答案 0 :(得分: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>

其余的问题是缺少标题的后果 - 编译器在没有所需的所有信息的情况下正在努力避免产生无根据的错误。

相关问题