centos5.4安装gcc

不能上网,利用光盘安装 gcc 和 gcc-c++的方法如下:

首先把光盘放入光驱内,虚拟机内的话就用 iso 光盘镜像就可以了。

然后如下:

[root@localhost ~]# more gcc_install.sh

#!/bin/bash
mount /dev/cdrom /mnt
cd /mnt/CentOS/
rpm -ivh glibc-common-2.5-42.i386.rpm
rpm -ivh kernel-headers-2.6.18-164.el5.i386.rpm
rpm -ivh libgcc-4.1.2-46.el5.i386.rpm
rpm -ivh glibc-2.5-42.i686.rpm
rpm -ivh cpp-4.1.2-46.el5.i386.rpm
rpm -ivh libgomp-4.4.0-6.el5.i386.rpm
rpm -ivh nscd-2.5-42.i386.rpm
rpm -ivh glibc-headers-2.5-42.i386.rpm
rpm -ivh glibc-devel-2.5-42.i386.rpm
rpm -ivh gcc-4.1.2-46.el5.i386.rpm
echo "gcc is installed successful!!!"
rpm -ivh libstdc++-4.1.2-46.el5.i386.rpm
rpm -ivh libstdc++-devel-4.1.2-46.el5.i386.rpm
rpm -ivh gcc-c++-4.1.2-46.el5.i386.rpm
echo "gcc-c++ is installed successful!!!"

[root@localhost ~]# chmod +x gcc_install.sh


[root@localhost ~]# ./gcc_install.sh
mount: block device /dev/cdrom is write-protected, mounting read-only
warning: glibc-common-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
package glibc-common-2.5-42.i386 is already installed
warning: kernel-headers-2.6.18-164.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:kernel-headers         ########################################### [100%]
warning: libgcc-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
package libgcc-4.1.2-46.el5.i386 is already installed
warning: glibc-2.5-42.i686.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
package glibc-2.5-42.i686 is already installed
warning: cpp-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
package cpp-4.1.2-46.el5.i386 is already installed
warning: libgomp-4.4.0-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:libgomp                ########################################### [100%]
warning: nscd-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
package nscd-2.5-42.i386 is already installed
warning: glibc-headers-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:glibc-headers          ########################################### [100%]
warning: glibc-devel-2.5-42.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:glibc-devel            ########################################### [100%]
warning: gcc-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:gcc                    ########################################### [100%]
gcc is installed successful!!!
warning: libstdc++-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
package libstdc++-4.1.2-46.el5.i386 is already installed
warning: libstdc++-devel-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:libstdc++-devel        ########################################### [100%]
warning: gcc-c++-4.1.2-46.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
   1:gcc-c++                ########################################### [100%]
gcc-c++ is installed successful!!!


[root@localhost ~]# gcc
gcc: no input files


[root@localhost ~]#

这样就成功了,注意我这里用的是CentOS 5.4, 假如你用的CentOS是其他版本的话,就得上光盘中看看,rpm包的名字改变了没有,注意其实也是是版本号发生了变化。。。

你可能感兴趣的:(centos,职场,休闲,centos5.4安装gcc)