1. 程式人生 > >Linux安裝gcc

Linux安裝gcc

Linux下自動安裝gcc

第一步:執行安裝命令 yum install gcc

但是我在安裝的過程中一直報錯:
報錯內容(部分):
Error Downloading Packages:

mpfr-2.4.1-6.el6.x86_64: failure: Packages/mpfr-2.4.1-6.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

libgomp-4.4.7-17.el6.x86_64: failure: Packages/libgomp-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

gcc-c+±4.4.7-17.el6.x86_64: failure: Packages/gcc-c+±4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

libgcc-4.4.7-17.el6.x86_64: failure: Packages/libgcc-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

cpp-4.4.7-17.el6.x86_64: failure: Packages/cpp-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

libstdc+±4.4.7-17.el6.x86_64: failure: Packages/libstdc+±4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

gcc-4.4.7-17.el6.x86_64: failure: Packages/gcc-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

cloog-ppl-0.15.7-1.2.el6.x86_64: failure: Packages/cloog-ppl-0.15.7-1.2.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

ppl-0.10.2-11.el6.x86_64: failure: Packages/ppl-0.10.2-11.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

libstdc+±devel-4.4.7-17.el6.x86_64: failure: Packages/libstdc+±devel-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

第二步 清理快取:

yum clean all

yum makecache

但仍舊報錯:
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was

14: PYCURL ERROR 6 - “Couldn’t resolve host ‘mirrorlist.centos.org’”

Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

[[email protected] softback]# yum -y install gcc gcc-c++ kernel-devel

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was

14: PYCURL ERROR 6 - “Couldn’t resolve host ‘mirrorlist.centos.org’”

Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

[[email protected] softback]# yum install gcc-c++ libstdc+±devel

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was

14: PYCURL ERROR 6 - “Couldn’t resolve host ‘mirrorlist.centos.org’”

Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

這種錯誤,是因為沒有配置/etc/resolv.conf。
解決方法:編輯resolv.conf檔案,新增:nameserver 8.8.8.8

第三步 配置檔案:vi resolv.conf

按字母i,進入插入模式,修改nameserver的值為 8.8.8.8
按Esc後,:wq儲存退出即可

第四步 執行 yum makecache 指令,等該指令結束後再執行安裝gcc指令

最後終於安裝成功啦,自己偷偷鼓個掌慶祝下