【问题标题】:Updating GCC on CentOS 6.2在 CentOS 6.2 上更新 GCC
【发布时间】:2016-02-19 04:09:23
【问题描述】:

今天我试图更新我的 gcc,在互联网上搜索后我发现了这个 article 但我被卡住了。我做了它所说的,但就像我的其他尝试一样得到了错误。在我的其他尝试中,我认为链接必须被破坏,但在这种情况下,这是一篇新文章,我认为我的计算机有问题。在那篇文章中,我只是使用更新部分,因为我已经有了 GCC 4.4.6 。我的问题是第一步:D。我输入了sudo yum install svn texinfo-tex flex zip libgcc.i686 glibc-devel.i686,但这里终端给了我Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again,我不知道这是什么意思。请不要重复这个问题,因为我搜索了很多,但我得到的错误一无所获。提前致谢。

这是 cmets 中要求的 /etc/yum.repos.d/epel.repo 文件。

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-    6&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

【问题讨论】:

  • 这意味着您在/etc/yum.repos.d/epel.repo 中的epel 存储库配置不正确(或者您应该重试,因为这是网络错误)。该文件包含什么?您要以这种方式安装 gcc 的哪个版本?你看过 CentOS 6 的 devtoolset-3 软件集合吗,它包含gcc 4.9.2。 (我相信你目前可以从softwarecollections.org 获得它,但它会在某个时候正式从 CentOS 提供,可能很快。)
  • 嗨@EtanReisner。我听取了您的建议并尝试下载 devtoolset-3。我打开了here。并输入了说明,但在第一步它给出了同样的错误。我还查找了/etc/yum.repos.d/epel.repo 文件,但在这里评论有点长。
  • 我认为 devtoolset-3 不需要 epel,因此您可以尝试将 --disablerepo=epel 添加到 yum 命令中,看看是否有帮助(暂时)。如果您不需要 epel(您可能不需要),您可以通过编辑 epel.repo 文件并将 enabled=1 更改为 enabled=0 默认禁用它,但这不是解决方案,只是一种解决方法。无论如何,将文件放在评论中将是一个糟糕的主意。使用内容编辑您的帖子。
  • 我已经在文件中进行了更改并且它有效。直到第4步:(。我想我要放弃了:(
  • [epel] 存储库的镜像列表条目已损坏。您需要将epel-& 替换为epel-6&

标签: linux gcc centos


【解决方案1】:

不是 100% 确定您的要求,但是:

EPEL

有安装 EPEL repo 的 RPM。这是链接:

rpm -i http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

在安装之前,你需要删除你已经应用的 EPEL conf 文件。

安装后,你需要做的

yum update

它会更新整个系统,包括 gcc。

请注意,此更新将不会将 CentOS 更新到版本 7 或其他版本。它只会使所有软件包都成为最新版本 - 例如,您将拥有最新的支持版本的 Apache 网络服务器。

海合会

问题的第二部分是关于 gcc - 即使在 EPEL 中,gcc 也有点老了。我自己的 C++11 代码,从不编译。

你需要安装一个叫做redhat developer toolset 1.1的东西:
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Developer_Toolset/1/html/1.1_Release_Notes/ch-Features.html

要安装它,您需要创建如下文件:

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++

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

此 repo 不会更新 /opt/ 之外的任何内容。

要使用编译器,您需要导出以下变量:

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++

可悲的是,即使这样,你也不能得到 gcc 4.8,但 gcc 版本是相当好的。我们能够通过只修补一个文件来编译最新的 node.js,但我们无法编译最新的 TokuDB。

叮当

你试过clang吗?因为 CentOS 不依赖于clang,所以它是相当新的版本,甚至可能支持 C++14。

希望这会有所帮助。

gcc repo 来源:
https://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos

【讨论】:

  • 我看到有人已经给你红帽开发工具回购了。它安装在 /opt 中,因此您需要导出大量环境变量,例如 CC 和 CPP。
  • 谢谢。这是我宿舍的电脑,很旧。这台计算机也是站点的服务器,因此我无法更新操作系统。顺便说一句,这是可行的,但我不知道该怎么做。谢谢你的帮助。我要放弃了。
  • 您不需要更新操作系统。 EPEL 版本显示为 6.8 但没关系。 6.2 与 6.XX 相同。 yum update 只会更新需要更新的包。我这么说是因为 EPEL 通常比常规 repo 有最新版本。 devtools repo 的一条评论 - 它不会更新 /opt 之外的任何内容,并且完全“无害”。
  • 嗨,我在here 中做了所有事情。而且没有问题。但是gcc --version 仍然显示4.4.7。但后来我看到了this。现在它显示gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)。但我仍然无法编译该代码。
  • 试试 clang 吗?你可以随时删除它吗? yum install clang
【解决方案2】:

开发者工具集 2.0 http://linux.web.cern.ch/linux/devtoolset/

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

你得到 gcc-4.8.1# yum install devtoolset-2-gcc-c++

64位http://linuxsoft.cern.ch/cern/devtoolset/slc6X/x86_64/RPMS/

32位http://linuxsoft.cern.ch/cern/devtoolset/slc6X/i386/RPMS/


【讨论】:

  • 这是为scientifi linux设计的吗?它也适用于 centos 6.x 吗?
  • 没区别 Redhat EL6.7 , CentOS 6.7 , ScientificLinux SL 6.7 ......都一样。相同的代码库等。ftp.redhat.com/redhat/linux/enterprise/6Server/en/os/SRPMS .... 并且:Developer Toolset 2.0 在我的 CentOS 6.7 安装中运行良好:# yum install devtoolset-2-gcc-c++
猜你喜欢
  • 2023-03-11
  • 2013-04-22
  • 2012-08-31
  • 2012-03-10
  • 2012-03-14
  • 1970-01-01
  • 2014-04-28
  • 2014-07-02
  • 2012-05-03
相关资源
最近更新 更多