linux(CentOS7)下安裝gcc

1linux中沒有默認安裝的gcc,通過yum發現沒有可用軟件包gcc

原因:這個系統沒有註冊到Red Hat訂閱管理。你可以使用訂閱管理器來註冊,說白了就是要收費,不給錢不讓用。。。。

2、查看系統版本:

百度red hat官方的rhel操作系統版本號與內核版本號的對應關係----CentOS 7

3、解決辦法:

百度了很多,也試驗了不少 ,教程都很亂。最後還是成功了,所以必須寫下來。

不多抱怨,上乾貨!!!

在這非常感謝https://blog.csdn.net/jianm_liu/article/details/78316690  這篇文章的作者,代碼可以從這邊複製!!

更換CentOS的yum源,使用163的源(此方式要確定服務器能上網

1、看看原來的yum都有什麼 

 

2、備份原yum,畢竟隨意刪除不是好習慣,萬一這個方法不成功呢。。。

 

3、刪除red hat yum源

4、再執行A步驟,看看是否刪除了,不看也行

5、去http://mirrors.163.com/centos/7/os/x86_64/Packages/下載如下文件,至於放到哪自己記住就行

也可以直接命令下載  wget http://…….

6、安裝新的yum 包

(1)

(2)

(3)

(4)

(5)

 

這裏做點着重介紹。。。重點。。。。(包括出現的錯誤)

  1. 相互依賴的包要一起安裝(上邊第五步!)
  2. 有教程上沒有說要下劃紅色箭頭的那倆rpm,如果不安裝的話會出現下邊的問題。提示你要下載那倆!

 

3、--force --nodeps 的使用(自己百度爲什麼)

 7、現在的yum查看

 

 

8、CentOSyum源更新到red hat
下載地址:http://mirrors.163.com/.help/centos.html

編輯文件內容  版本號$releasever改爲7,保存文件名爲CentOS7-Base-163.repo,路徑什麼的對應好自己的。

然後把它放到/etc/yum.repos.d/下(mv也好  通過Xftp放也好)

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7-Base
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7-Plus 
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

 

 9、執行下邊兩部

 

10:最後就是安裝gcc了,安裝完驗證 ,成功了

 

 

第一次寫,寫的不好,見諒。希望此貼能對你有所幫助!!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章