如何在 CentOS 上安装 gcc 4.7.x/4.8.x

Tom*_*rle 91 centos yum rpm

gcc在 CentOS 6.2+ 的系统上安装4.7.x/4.8.x的最简单方法是什么?默认的 RPM 包包含旧版本的gcc.

ck_*_*ck_ 68

centos.org 的 Tru Huynh为 centos构建了redhat 开发者工具集 1.1,其中包含 gcc 4.7.2

所以你可以简单地使用他的 repo 并立即安装 gcc。

cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo 
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++
Run Code Online (Sandbox Code Playgroud)

这将很可能将其安装到 /opt/centos/devtoolset-1.1/root/usr/bin/

然后你可以告诉你的编译过程使用 gcc 4.7 而不是 4.4 和 CC 变量

export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc  
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
Run Code Online (Sandbox Code Playgroud)

  • 对于 g++ 4.8.2,将 `1.1` 处处更改为 `2`,并将 `--enablerepo=testing-1.1-devtools-6` 更改为 `--enablerepo=testing-devtools-2-centos-6` (13认同)
  • 您可以执行`scl enable devtoolset-1.1 bash`(它启动新的shell 并设置所有变量),而不是设置单个变量。 (6认同)
  • 运行 `yum --enablerepo=testing-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++` 返回四对四,.. : [image](http://img690.imageshack.us /img690/354/screenshotrafalcentos6v.png) (5认同)
  • 这仍然有效吗?我得到 http://people.centos.org/tru/devtools-2/6Workstation/i386/RPMS/repodata/repomd.xml: [Errno 14] PYCURL 错误 22 - “请求的 URL 返回错误:404” (3认同)

Mar*_*ata 43

以下是如何获取 devtoolset-2(包括 gcc 4.8.1)

这是摘自http://people.centos.org/tru/devtools-2/readme

wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
Run Code Online (Sandbox Code Playgroud)

已知的问题:

  • 未签名的包裹
  • CentOS-6 devtoolset-2 需要 devtoolset-2-ide,它包含整个 Eclipse 堆栈,但尚未构建
  • CentOS-6所有maven相关文件也没有构建

devtools-1.1 的主要变化:

  • /opt/centos 不再使用
  • /opt/rh 现在用作上游(作为 SL 版本)

  • @Swanidhi 完整命令是“scl enable devtoolset-2 bash”,如果您不使用 bash,最后一个字段可能会有所不同。 (3认同)
  • @JemiloII - 安装后你做了`scl enable devtoolset-2` 吗?这应该可以在路径上获得正确的编译器。 (2认同)

小智 29

有新版本的 devtoolset 2.0。来自 Cern 从事 Scientific Linux 工作的好人创建了一个开放版本

如果您使用 CentOS(而不是 Scientific Linux),那么您必须使用以下命令从这里导入他们的 GPG 密钥:

rpm --import http://www.scientificlinux.org/documentation/gpg/RPM-GPG-KEY-cern
Run Code Online (Sandbox Code Playgroud)

享受!


Den*_*sov 21

# 1. Install a package with repository for your system:
# RHEL 6: `yum-config-manager --enable rhel-server-rhscl-6-rpmss`
# RHEL 7: `yum-config-manager --enable rhel-server-rhscl-7-rpms`
$ sudo yum install centos-release-scl # On CentOS 6/7+, install package centos-release-scl available in CentOS repository

# 2. Install the collection:
$ sudo yum install devtoolset-3

# 3. Start using software collections:
$ scl enable devtoolset-3 bash

$ sudo yum list devtoolset-3\*
Run Code Online (Sandbox Code Playgroud)


bba*_*a42 2

从gnu gcc中可以看到,最新的稳定版本是 4.62。4.7版本可以下载并编译,更多关于gcc安装的信息。