2016-03-31 196 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等。