2016-03-31 171 views
33

我使用CentOS的7.2如何在CentOS 7.2上安装带有yum的gcc 5.3?

当我使用yum groupinstall "Development Tools",GCC 4.8.5是,像这样:

enter image description here

我想安装gcc 5.3

如何使用这个办法yum

+0

按照这个教程https://www.vultr.com/docs/how-to-install-gcc-on-centos-6 –

+0

@MohammadShahadatHossain有没有'yum'资源在哪里? – sunshine

+0

我不确定,但在这种情况下,您可以使用此处的RPM资源。 https://www.rpmfind.net/linux/rpm2html/search.php?query=gcc –

回答

30

更新:

安装GCC 7.3 (gcc 7.3.0) - 发布2018年1月25日

下载文件:https://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz

编译安装:

结果:

enter image description here

安装GCC 5.5(gcc 5.5.0) - 发布二○一七年十月一十日

下载文件:https://ftp.gnu.org/gnu/gcc/gcc-5.5.0/gcc-5.5.0.tar.gz

//required libraries: 
yum install libmpc-devel mpfr-devel gmp-devel zlib-devel* 

//if the minimum version and dev tools are not installed yet 
yum install gcc 
yum groupinstall "Development Tools" 

//configure, compile and install 
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++ 

make -j 8 <== this may take around 40 minutes to finish with 8 threads 

make install 

enter image description here

老答案:

眼下,没有rpm包,以便于CentOS 7.2 yum来安装gcc 5.3甚至7.3的CentOS

的解决办法是安装GCC 5。3从source code

1:Intstall所需库

sudo yum install libmpc-devel mpfr-devel gmp-devel 

接受在该步骤中安装CentOS GPG Key

enter image description here

安装 - zlib的

yum install zlib-devel* 

2:下载所需的源和安装

curl ftp://ftp.gnu.org/pub/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2 -O 

//If you want to verify the downloaded file, use this sig file: 
ftp://ftp.gnu.org/pub/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2.sig 

tar xvfj gcc-5.3.0.tar.bz2 

cd gcc-5.3.0 

//here you can add other languages you want to be supported for your gcc like Java or Go,... 
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++ 

// 4 = number of independent central processing units (# of Cores) 
make -j 4 

make install 

验证版本:

enter image description here

注:

This Stack Overflow answer将有助于了解如何验证下载的源文件。

2.使用选项--prefix将gcc安装到默认目录以外的其他目录。顶层安装目录默认为/ usr/local。 Read about gcc installation options

+0

为什么从ftp.mirrorservice.org而不是ftp.gnu.org下载?您还应该下载并验证相应的'.sig'文件(pgp签名)。 –

+0

我更新了答案 – HDJEMAI

+0

配置如下所示--prefix将安装在/ usr/local /中,它可能会也可能不会在路径上的原始gcc安装之前提交 – tim18

64

更新 人们常常希望最近的gcc版本,devtoolset正在跟上最新的,所以也许你想devtoolset-N,其中N = {4,5,6,7 .. 。},请检查yum以获取您系统上的最新版本)。更新N = 7以下的cmds。

有一个gcc-5.2.1包,如果这足够接近。首先,你需要启用Software Collections,那么它在devtoolset-4的可用:

sudo yum install centos-release-scl 
sudo yum install devtoolset-7-gcc* 
scl enable devtoolset-7 bash 
which gcc 
gcc --version 
+2

devtoolset中的gcc版本已经同时碰到5.3.1 – tesch1

+4

不仅如此,而且你可以安装devtoolset-6来获取6.2.1 – Rahly

+0

谢谢,你救了我的一天!另外,我发现我的/ usr/bin/C++仍然与gcc 4.8.5链接,因此我必须重新链接到gcc 6:'ln -sf/opt/rh/devtoolset-6/root/usr/bin/g ++/usr/bin/C++' –

-7

命令到一个CentOS/RHEL 7服务器

键入以下百胜命令,作为根用户在安装GCC和开发工具:

百胜餐饮集团安装 “开发工具”

OR

sudo的百胜餐饮集团安装 “开发工具”

如果上面的命令失败,请尝试:

百胜groupinstall“开发工具”

1

使用百胜和更新devtoolset是利用CentOS的SCLo RH测试库的最佳方法。

yum install centos-release-scl-rh 
yum --enablerepo=centos-sclo-rh-testing install devtoolset-7-gcc devtoolset-7-gcc-c++ 

许多额外的软件包都还可以,看到他们所有

yum --enablerepo=centos-sclo-rh-testing list devtoolset-7* 

您可以使用此方法来安装任何开发工具版本,只是换了7您想要的版本。 devtoolset-6-gcc,devtoolset-5-gcc等。

相关问题