当前位置: > CentOS > CentOS教程 >

CentOS下安装gcc /g++ /gfortran /g77 编译器

时间:2016-06-04 17:04来源:linux.it.net.cn 作者:IT
以前用的Ubuntu较多,最近刚刚接触CentOS,感觉两个版本的差别还是较大的。http://hxhg.gxu.edu.cn/lsq/?act=article&code=detail&cid=67&id=52

完全新手入门的角度,学习CentOS..版本centos 6.2  x86_64


由于手头有CentOS 6.2的安装光盘,所以采用的是rpm包来安装gcc编译器,这样免去来下载安装包的步骤。。(其他的安装方法还有待学习)

1.a:将DVD光盘插入光驱,   b:将所需的rpm包拷贝到系统某个目录下(需要哪些后面有讲);

2.a,b两种方式选一个,并cd到放置rpm软件包的目录下;

    以a方法为例,插入光盘后 : cd /media/CentOS_6.2_Final/Packages

    注:CentOS 6.0以后,这些rpm都是在光盘目录下的Packages目录下,6.0以前好像是在Server文件夹下

    ps:不能确定rpm包名称的时候,或者想要下载rpm包的时候,强烈推荐大家用google搜索,因为至少在搜索   rpm包、安装源这方面,百度是个渣渣

3.开始安装,命令如下,顺序一定不能出错:


rootsuroot......



rpm -ivh kernel-headers-2.6.32-220.el6.x86_64.rpm

 rpm -ivh glibc-headers-2.12-1.47.el6.x86_64.rpm --force --nodeps

rpm -ivh glibc-devel-2.12-1.47.el6.x86_64.rpm --force --nodeps

rpm -ivh libgomp-4.4.6-3.el6.x86_64.rpm

 rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm

 rpm -ivh cpp-4.4.6-3.el6.x86_64.rpm

rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm

rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm

rpm -ivh gcc-4.4.6-3.el6.x86_64.rpm

 rpm -ivh libstdc++-devel-4.4.6-3.el6.x86_64.rpm

rpm -ivh gcc-c++-4.4.6-3.el6.x86_64.rpm

rpm –ivh后面的就是需要的rpm软件包,英文字母应该是和我一样的,但是数字可能不容,因为版本号不一样

这样gcc编译器安装完成。

输入 gcc -v 会显示安装的版本

使用内建 specs。
目标:x86_64-redhat-linux
配置为:../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
线程模型:posix
gcc 版本 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)


安装完成gcc后发现 gcc -v 和g++ -v都能显示,唯独gfortran -v时显示 gfortran命令没有找到,说明gfortran没有安装。
命令安装如下:
 (1)命令安装gcc
      yum install gcc
(2)安装g++
      yum install gcc-c++
结果显示gcc-c++已被成功安装,所以这样运行安装gfortran应该也不会出现问题
  (3)安装gfortran
      yum install gcc-gfortran
  然后一路yes。。
运行gfortran -v 显示安装版本。。成功。。


补充g77的安装。

依旧是在/media/CentOS_6.2_Final/Packages目录下:
 
[root@TTWORKTEAM Packages]# yum search g77
结果显示:

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
=============================== N/S Matched: g77 ===============================
compat-gcc-34-g77.x86_64 : Fortran 77 support for compatibility compiler

  Name and summary matches only, use "search all" for everything.

可以看到有一个软件包compat-gcc-34-g77.x86_64为g77编译器 ,命令安装如下:

[root@TTWORKTEAM Packages]# yum install compat-gcc-34-g77-3.4.6-19.el6.x86_64.rpm
过程显示:(一直选择Y,默认安装。。。)

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
Setting up Install Process
Examining compat-gcc-34-g77-3.4.6-19.el6.x86_64.rpm: compat-gcc-34-g77-3.4.6-19.el6.x86_64
Marking compat-gcc-34-g77-3.4.6-19.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package compat-gcc-34-g77.x86_64 0:3.4.6-19.el6 will be installed
--> Processing Dependency: compat-gcc-34 = 3.4.6-19.el6 for package: compat-gcc-34-g77-3.4.6-19.el6.x86_64
--> Processing Dependency: compat-libf2c-34 = 3.4.6-19.el6 for package: compat-gcc-34-g77-3.4.6-19.el6.x86_64
--> Processing Dependency: libg2c.so.0()(64bit) for package: compat-gcc-34-g77-3.4.6-19.el6.x86_64
--> Running transaction check
---> Package compat-gcc-34.x86_64 0:3.4.6-19.el6 will be installed
---> Package compat-libf2c-34.x86_64 0:3.4.6-19.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch   Version      Repository                          Size
================================================================================
Installing:
 compat-gcc-34-g77 x86_64 3.4.6-19.el6 /compat-gcc-34-g77-3.4.6-19.el6.x86_64
                                                                          5.9 M
Installing for dependencies:
 compat-gcc-34     x86_64 3.4.6-19.el6 base                               3.7 M
 compat-libf2c-34  x86_64 3.4.6-19.el6 base                                51 k

Transaction Summary
================================================================================
Install       3 Package(s)

Total size: 9.6 M
Total download size: 3.8 M
Installed size: 19 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): compat-gcc-34-3.4.6-19.el6.x86_64.rpm             | 3.7 MB     00:00    
(2/2): compat-libf2c-34-3.4.6-19.el6.x86_64.rpm          |  51 kB     00:00    
--------------------------------------------------------------------------------
Total                                           7.2 MB/s | 3.8 MB     00:00    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : compat-gcc-34-3.4.6-19.el6.x86_64                            1/3
  Installing : compat-libf2c-34-3.4.6-19.el6.x86_64                         2/3
  Installing : compat-gcc-34-g77-3.4.6-19.el6.x86_64                        3/3

Installed:
  compat-gcc-34-g77.x86_64 0:3.4.6-19.el6                                      

Dependency Installed:
  compat-gcc-34.x86_64 0:3.4.6-19.el6   compat-libf2c-34.x86_64 0:3.4.6-19.el6 

Complete!

安装完成,用命令g77 -v检测安装是否成功和查看安装路径。

[root@TTWORKTEAM Packages]# g77 -v
从 /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs 读取 specs
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=x86_64-redhat-linux
线程模型:posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-19.el6)



(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容