yum安装gcc

时间:2022-02-16 05:50:15

  如果服务器是自己的,并且机器就在身边,那什么都不用说了,缺少gcc顶多就是重新放入安装盘,把开发工具包安装上。但是如果是租的服务器,托管服务 方那帮人又搞不懂你说的啥子gcc,要安装gcc实在是太麻烦了。你得去找gcc相关的包,版本号还得必须对应上,否则不兼容。最近给一个朋友装gcc, 着实头疼了一把。后来发现yum这个好东西,只需要执行一个命令,所有的烦恼都解除了。

朋友的系统是CentOS 5 的,托管商没给安装gcc,于是使用如下两个命令就可把gcc,gcc-c++统统安装上:

yum -y install gcc

yum -y install gcc-c++

yum会自动查找软件的相关依赖包,自动下载安装,全过程轻松愉快。特此记录一下。

[root@localhost Jorcen]# yum -y install gcc
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
livna | 1.3 kB :
rpmfusion-free-updates | 3.3 kB :
rpmfusion-nonfree-updates | 3.3 kB :
updates//x86_64/metalink | 4.0 kB :
updates | 4.9 kB :
updates//x86_64/primary_db | MB :
(/): rpmfusion-nonfree-updates//x86_64/primary_db | kB :
(/): updates//x86_64/updateinfo | 1.2 MB :
(/): updates//x86_64/pkgtags | 1.0 MB :
Loading mirror speeds from cached hostfile
* fedora: mirrors.oschina.net
* livna: ftp-stud.fht-esslingen.de
* rpmfusion-free: mirror.bjtu.edu.cn
* rpmfusion-free-updates: mirror.bjtu.edu.cn
* rpmfusion-nonfree: mirror.bjtu.edu.cn
* rpmfusion-nonfree-updates: mirror.bjtu.edu.cn
* updates: mirrors.oschina.net
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 :4.8.-.fc19 will be installed
--> Processing Dependency: cpp = 4.8.-.fc19 for package: gcc-4.8.-.fc19.x86_64
--> Processing Dependency: glibc-devel >= 2.2.- for package: gcc-4.8.-.fc19.x86_64
--> Processing Dependency: libmpc.so.()(64bit) for package: gcc-4.8.-.fc19.x86_64
--> Running transaction check
---> Package cpp.x86_64 :4.8.-.fc19 will be installed
---> Package glibc-devel.x86_64 :2.17-.fc19 will be installed
--> Processing Dependency: glibc-headers = 2.17-.fc19 for package: glibc-devel-2.17-.fc19.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-.fc19.x86_64
---> Package libmpc.x86_64 :1.0.-.fc19 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 :2.17-.fc19 will be installed
--> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
gcc x86_64 4.8.-.fc19 updates M
Installing for dependencies:
cpp x86_64 4.8.-.fc19 updates 5.9 M
glibc-devel x86_64 2.17-.fc19 updates 1.0 M
glibc-headers x86_64 2.17-.fc19 updates k
libmpc x86_64 1.0.-.fc19 fedora k Transaction Summary
======================================================================================================================================================
Install Package (+ Dependent packages) Total download size: M
Installed size: M
Downloading packages:
cpp-4.8.-.fc19.x86_64.rpm FAILED ] kB/s | kB :: ETA
http://mirror.nus.edu.sg/fedora/linux/updates/19/x86_64/cpp-4.8.2-7.fc19.x86_64.rpm: [Errno 14] HTTP Error 403 - ForbiddenkB/s | 251 kB 00:09:16 ETA
Trying other mirror.
glibc-headers-2.17-.fc19.x86 FAILED ] kB/s | kB :: ETA
http://mirror.nus.edu.sg/fedora/linux/updates/19/x86_64/glibc-headers-2.17-20.fc19.x86_64.rpm: [Errno 14] HTTP Error 403 - Forbidden kB 00:08:02 ETA
Trying other mirror.
(/): libmpc-1.0.-.fc19.x86_64.rpm | kB ::
(/): glibc-devel-2.17-.fc19.x86_64.rpm | 1.0 MB ::
(/): cpp-4.8.-.fc19.x86_64.rpm | 5.9 MB ::
(/): glibc-headers-2.17-.fc19.x86_64.rpm | kB ::
(/): gcc-4.8.-.fc19.x86_64.rpm | MB ::
------------------------------------------------------------------------------------------------------------------------------------------------------
Total kB/s | MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libmpc-1.0.-.fc19.x86_64 /
Installing : cpp-4.8.-.fc19.x86_64 /
Installing : glibc-headers-2.17-.fc19.x86_64 /
Installing : glibc-devel-2.17-.fc19.x86_64 /
Installing : gcc-4.8.-.fc19.x86_64 /
Verifying : cpp-4.8.-.fc19.x86_64 /
Verifying : glibc-headers-2.17-.fc19.x86_64 /
Verifying : glibc-devel-2.17-.fc19.x86_64 /
Verifying : gcc-4.8.-.fc19.x86_64 /
Verifying : libmpc-1.0.-.fc19.x86_64 / Installed:
gcc.x86_64 :4.8.-.fc19 Dependency Installed:
cpp.x86_64 :4.8.-.fc19 glibc-devel.x86_64 :2.17-.fc19 glibc-headers.x86_64 :2.17-.fc19 libmpc.x86_64 :1.0.-.fc19 Complete!

install gcc-c++

[root@localhost Jorcen]# yum -y install gcc-c++
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
Loading mirror speeds from cached hostfile
* fedora: mirrors.yun-idc.com
* livna: ftp-stud.fht-esslingen.de
* rpmfusion-free: mirror.bjtu.edu.cn
* rpmfusion-free-updates: mirror.bjtu.edu.cn
* rpmfusion-nonfree: mirror.bjtu.edu.cn
* rpmfusion-nonfree-updates: mirror.bjtu.edu.cn
* updates: mirrors.yun-idc.com
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 :4.8.-.fc19 will be installed
--> Processing Dependency: libstdc++-devel = 4.8.-.fc19 for package: gcc-c++-4.8.-.fc19.x86_64
--> Running transaction check
---> Package libstdc++-devel.x86_64 :4.8.-.fc19 will be installed
--> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================================
Installing:
gcc-c++ x86_64 4.8.-.fc19 updates 7.1 M
Installing for dependencies:
libstdc++-devel x86_64 4.8.-.fc19 updates 1.5 M Transaction Summary
======================================================================================================================================================
Install Package (+ Dependent package) Total download size: 8.6 M
Installed size: M
Downloading packages:
(/): libstdc++-devel-4.8.-.fc19.x86_64.rpm | 1.5 MB ::
(/): gcc-c++-4.8.-.fc19.x86_64.rpm | 7.1 MB ::
------------------------------------------------------------------------------------------------------------------------------------------------------
Total kB/s | 8.6 MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libstdc++-devel-4.8.-.fc19.x86_64 /
Installing : gcc-c++-4.8.-.fc19.x86_64 /
Verifying : libstdc++-devel-4.8.-.fc19.x86_64 /
Verifying : gcc-c++-4.8.-.fc19.x86_64 / Installed:
gcc-c++.x86_64 :4.8.-.fc19 Dependency Installed:
libstdc++-devel.x86_64 :4.8.-.fc19 Complete!

other

yum -y install gcc
yum -y install gcc-c++
yum install make -- 或者
yum groupinstall "Development Tools" -- 或者
yum install gcc gcc-c++ kernel-devel