0

我是红帽企业 Linux 的新手。我在 Red Hat Enterprise Linux 6.5 上编译 gcc 4.8.2 时遇到问题,我下载了 GNU 网站的源代码。我遵循此链接 http://gcc.gnu.org/wiki/InstallingGCC中的步骤 触发的命令是:

tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.2/configure 

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... gnatbind
checking for gnatmake... gnatmake
checking whether compiler driver understands Ada... yes
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.

我在 Google 上进行了调查,然后我发现以下与此 http://gcc.gnu.org/ml/gcc-help/2012-02/msg00142.html相关的问题, 但它再次将我重定向到我之前找到并遵循的上述链接。

我需要有关如何处理此问题的指导。欢迎提出建议。

4

2 回答 2

9

在 RHEL 6 上安装 gcc 4.8.2 的官方方法是安装 Red Hat Developer Toolset (yum install devtoolset-2),为了拥有它,您需要拥有以下订阅之一:

  • 红帽企业 Linux 开发人员支持,专业
  • 红帽企业 Linux 开发人员支持,企业
  • 红帽企业 Linux 开发人员套件
  • 红帽企业 Linux 开发人员工作站,专业版
  • 红帽企业 Linux 开发者工作站,企业
  • 30 天自助红帽企业 Linux 开发人员工作站评估
  • 60 天支持的红帽企业 Linux 开发人员工作站评估
  • 90 天支持的红帽企业 Linux 开发人员工作站评估
  • 1 年不受支持的合作伙伴评估 Red Hat Enterprise Linux
  • 1 年不受支持的红帽高级合作伙伴订阅

您可以通过运行以下命令检查您是否有任何这些订阅:

subscription-manager list --available

subscription-manager list --consumed.

如果您没有任何这些订阅,您将无法成功执行“yum install devtoolset-2”。然而,幸运的是,cern 为他们的 SLC6 提供了一个“后门”,它也可以在 RHEL 6 中使用。通过 root 运行以下三行,你应该能够拥有它:

wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-cern http://ftp.scientificlinux.org/linux/scientific/5x/x86_64/RPM-GPG-KEYs/RPM-GPG-KEY-cern

yum install devtoolset-2

完成后,您应该在 /opt/rh/devtoolset-2/root/ 中拥有新的开发包。

于 2016-01-29T21:53:49.100 回答
1

由于某种原因,没有下载 mpc/mpfr/gmp 包。只需查看您的 gcc 源目录,它应该已经创建了指向这些包的符号链接:

gcc/4.9.1/install$ ls -ad gmp mpc mpfr
gmp  mpc  mpfr

如果这些没有出现,那么只需从 gcc 站点下载它们:ftp: //gcc.gnu.org/pub/gcc/infrastructure/

然后解压缩并符号链接/重命名它们,这样你就有了上面的目录。然后当你 ./configure 和 make 时,gcc 的 makefile 会自动为你构建它们。

于 2014-10-29T21:53:39.143 回答