CentOS7/6使用rpm离线安装gcc7/6
1.安装gcc之前需要确认CentOS的版本,版本不同安装的gcc也不同,可以使用以下命令进行查看,我的服务器版本是6.5
注意:版本一定要对应,不然安装不上,亲测各种出错.
[root@localhost bin]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@localhost bin]# cat /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
2.下载gcc对应的rpm包
①这些rpm包都可以在rpm仓库找到,链接如下:
http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
CentOS7需要下载的rpm包为:最后一个tcl是在make test的时候需要,可以不装,无所谓.
②如果是centos6可以参考如下地址:
http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/
CentOS6需要下载的rpm包为(6.5和6的rpm包是一样的,可以参看链接6.5的readme):
3.将文件上传至服务器,我使用的ftp工具将文件传至/opt文件夹下
4.安装gcc
①CentOS7安装很简单直接进入rpm目录,一个命令安装即可.
rpm -ivh *.rpm --nodeps --force
安装完成可以输入gcc -v进行测试
②CentOS6安装相对复杂,进入rpm目录,依次进行安装
rpm -Uvh mpfr-2.4.1-6.el6.x86_64.rpm
rpm -Uvh cpp-4.4.7-23.el6.x86_64.rpm
rpm -Uvh libgomp-4.4.7-23.el6.x86_64.rpm
rpm -Uvh libgcc-4.4.7-23.el6.x86_64.rpm
rpm -Uvh ppl-0.10.2-11.el6.x86_64.rpm
rpm -Uvh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
rpm -Uvh gcc-4.4.7-23.el6.x86_64.rpm
测试也是一样:gcc -v
大概是介个样子的
[root@localhost gcc-rpm]# ls
cloog-ppl-0.15.7-1.2.el6.x86_64.rpm libgomp-4.4.7-23.el6.x86_64.rpm
cpp-4.4.7-23.el6.x86_64.rpm mpfr-2.4.1-6.el6.x86_64.rpm
gcc-4.4.7-23.el6.x86_64.rpm ppl-0.10.2-11.el6.x86_64.rpm
libgcc-4.4.7-23.el6.x86_64.rpm
[root@localhost gcc-rpm]# rpm -Uvh mpfr-2.4.1-6.el6.x86_64.rpm
warning: mpfr-2.4.1-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:mpfr ########################################### [100%]
[root@localhost gcc-rpm]# rpm -Uvh cpp-4.4.7-23.el6.x86_64.rpm
warning: cpp-4.4.7-23.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:cpp ########################################### [100%]
[root@localhost gcc-rpm]# rpm -Uvh libgomp-4.4.7-23.el6.x86_64.rpm
warning: libgomp-4.4.7-23.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:libgomp ########################################### [100%]
[root@localhost gcc-rpm]# rpm -Uvh libgcc-4.4.7-23.el6.x86_64.rpm
warning: libgcc-4.4.7-23.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:libgcc ########################################### [100%]
[root@localhost gcc-rpm]# rpm -Uvh ppl-0.10.2-11.el6.x86_64.rpm
warning: ppl-0.10.2-11.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:ppl ########################################### [100%]
[root@localhost gcc-rpm]# rpm -Uvh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
warning: cloog-ppl-0.15.7-1.2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:cloog-ppl ########################################### [100%]
[root@localhost gcc-rpm]# rpm -Uvh gcc-4.4.7-23.el6.x86_64.rpm
warning: gcc-4.4.7-23.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:gcc ########################################### [100%]
[root@localhost gcc-rpm]# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
文章参考:
https://blog.csdn.net/qq_39314099/article/details/99842308
https://www.cnblogs.com/shijiaoyun/p/5909380.html