Centos

如何在 centos 7.1 上安裝 gcc 5.2?

  • September 7, 2015

如何在 centos 7.1 上安裝 gcc 5.2?用 g++,cpp 嗎?

我編譯過一次,但它需要更新的 glibc 不能在系統中切換

你可以從 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.

引用自:https://serverfault.com/questions/720558