【问题标题】:Installing GCC 4.8.2 on Red Hat Enterprise linux 6.5在 Red Hat Enterprise linux 6.5 上安装 GCC 4.8.2
【发布时间】:2014-08-21 18:07:51
【问题描述】:

我是 Red Hat Enterprise 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 但它再次将我重定向到我之前找到并遵循的上述链接。

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

【问题讨论】:

  • 如前所述,您必须拥有如错误日志中所示的上述库---gmpmpfrmpc
  • 我认为使用yum info 可以知道您是否安装了该实用程序。
  • 考虑只安装 Redhat Developer Toolset,它是一个附加组件,包含一些重要开发软件的更新版本,包括 GCC。商业 RedHat 版本在这里:access.redhat.com/documentation/en-US/Red_Hat_Developer_Toolset 免费相同的 CentOS 版本(适用于 RHEL)在这里:linux.web.cern.ch/linux/devtoolset
  • 您构建 GCC 是为了娱乐/学习还是因为您需要更新版本?
  • 我在您的帖子中看到了 4.6.2 和 4.8.2,您是否始终键入相同的版本?

标签: linux gcc gmp mpfr mpc


【解决方案1】:

在 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 年不受支持的合作伙伴评估红帽企业 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/ 中拥有新的开发包。

【讨论】:

【解决方案2】:

由于某种原因,没有下载 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 会自动为你构建它们。

【讨论】: