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

发布于 2024-08-30 04:06:18 字数 1453 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我只土不豪 2024-09-06 04:06:18

关键错误是:

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

G++ 抱怨它找不到 (尽管它在消息中省略了尖括号)这一事实意味着您遇到了某种编译器配置问题。您可能缺少一个重要的包。我希望重新安装或更新您的 GCC 环境,以便最终找到

其余的问题是缺少标头的后果 - 编译器在没有避免生成无根据的错误所需的所有信息的情况下苦苦挣扎。

The key error is:

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文