g++没有正确链接头文件
我正在使用 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!";
}
给了我同样的错误。
I am using cygwin libraries to run C and C++ programs on Windows.
gcc
runs fine, but with g++
, I get a long list of errors. I think these erros are because of linking problems with C libraries.
Can you suggest what I need to do to fix this?
beginning error lines:
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
the whole error dump:
PasteBin
for people asking for source code: this this is clearly a header file linking issue and happens before the compilation even starts. I get the same error for every .cpp file.
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(){
cout<<"hello world!";
}
gives me the very same error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关键错误是:
G++ 抱怨它找不到
(尽管它在消息中省略了尖括号)这一事实意味着您遇到了某种编译器配置问题。您可能缺少一个重要的包。我希望重新安装或更新您的 GCC 环境,以便最终找到
。其余的问题是缺少标头的后果 - 编译器在没有避免生成无根据的错误所需的所有信息的情况下苦苦挣扎。
The key error is:
The fact that G++ is complaining that it cannot find
<stdio.h>
(though it leaves the angle brackets out of the message) means you have a compiler configuration problem of some sort. Probably, you are missing a crucial package. I would look to reinstall or update your GCC environment, so that<stdio.h>
ends up being found.The rest of the problems are consequences of the missing header - the compiler is struggling on without all the information it needs to avoid generating unwarranted errors.