如何在 centos 7.1 上安装 gcc 5.2?使用 g++、cpp?
我编译过一次,但是需要较新的 glibc,无法在系统中切换
答案1
您可以从 fedora 创建 repo 并安装 gcc 5.1.1,这比编译它更好。
cat << EOF > /etc/yum.repos.d/Fedora-Core23.repo
[warning:fedora]
name=fedora
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-23&arch=$basearch
enabled=1
gpgcheck=0
EOF
然后安装 gcc
yum install gcc --enablerepo=warning:fedora
输出:
========================================================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================================================
Installing:
gcc x86_64 5.1.1-4.fc23 warning:fedora 19 M
Installing for dependencies:
cpp x86_64 5.1.1-4.fc23 warning:fedora 8.5 M
glibc-devel x86_64 2.22-2.fc23 warning:fedora 909 k
glibc-headers x86_64 2.22-2.fc23 warning:fedora 497 k
isl x86_64 0.14-4.fc23 warning:fedora 490 k
kernel-headers x86_64 4.2.0-1.fc23 warning:fedora 992 k
libmpc x86_64 1.0.2-4.fc23 warning:fedora 55 k
mpfr x86_64 3.1.3-1.fc23 warning:fedora 213 k
Updating for dependencies:
binutils x86_64 2.25-13.fc23 warning:fedora 5.6 M
glibc x86_64 2.22-2.fc23 warning:fedora 3.6 M
glibc-common x86_64 2.22-2.fc23 warning:fedora 11 M
libgcc x86_64 5.1.1-4.fc23 warning:fedora 82 k
libgomp x86_64 5.1.1-4.fc23 warning:fedora 146 k
Transaction Summary
========================================================================================================================================================================================================
Install 1 Package (+7 Dependent packages)
Upgrade ( 5 Dependent packages)
Total download size: 52 M
Is this ok [y/d/N]: y
为什么您更喜欢 gcc 5.2?
# gcc --version
gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
答案2
纳米/etc/yum.repos.d/FedoraRepo.repo
[warning:fedora]
name=fedora
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-23&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=https://getfedora.org/static/34EC9CBA.txt
yum 更新 gcc g++