如何让 GCC 检测标准 C 库?

How to make GCC detect standard C library?

我的问题如下: 为了构建一些特定的库,我必须在无法访问 Internet 且无法使用 yum.

的 red hat 上安装 GCC

现在我做到了:

1)我安装了 gcc-x86_64-linux-gnu(及其依赖项)

2) 我在 /usr/bin 中为以下已安装的可执行文件创建了符号链接:/usr/bin/x86_64-linux-gnu-cpp/usr/bin/x86_64-linux-gnu-gcc/usr/bin/x86_64-linux-gnu-gcov 使用 sudo ln -s /usr/bin/x86_64-linux-gnu-<end> <end> 所以我有功能 gcc cppgcov 命令。

3) 我在我的库上测试了一个 ./configure 来构建并得到 GCC 说 C 编译器无法创建 C 可执行文件。我测试了创建一个简单的 hello world C 程序。

#include<stdio.h>
int main(void){
        printf("hello world!\n");
        return 0;
}

当 运行 gcc ./hello.c -o hello 我得到这个错误: "fatal error : stdio.h : no such file or directory".

4) 我做了 ls /usr/include | grep .h 但一无所获。结论:未安装标准 C 库。

5) 我安装了 glibc-devel 以导入标准 C 库,现在相同的命令显示许多 C 文件,包括 stdio.h 文件。

但我的 GCC 仍然引发同样的致命错误。 知道我应该怎么做才能让它发挥作用吗?

我认为这里的问题与 this question

中建议的 x86 / x64 问题无关

根据你的 post 我认为这与安装不当有关,在安装包之前确保你使用正确的包来正确分发,因为 32 位或 64 位可能会出现兼容性问题 OS包。您可以使用 Red Hat Boot CD 尝试以下方法。

从 CDROM/DVD

安装 rpm

安装您的 RHEL Linux CD/DVD 并使用 rpm 命令安装以下软件包:

$rpm -ivh gcc*