首页 > 学院 > 操作系统 > 正文

菜鸟安装gcc

2024-06-28 13:28:20
字体:
来源:转载
供稿:网友
菜鸟安装gcc 2014-01-22 22:12 by Lan1115441, ... 阅读, ... 评论, 收藏, 编辑

  今天第一次写博客,刚好装了一个linux系统,发行版是fedora20,因为之前都是用centos6.4两个系统感觉操作上没差多少,相对而言fedora的界面更为美观一些。

  本人是打算用linux来写一些C程序,而linux下最为流行的应该要数gcc编译器了把。今天就装了一下gcc c

  (1)先获得管理员权限

    1)$su

    2)输入管理员密码

  (2)yum安装gcc

    (1)#yum install gcc(yum功能很强大)

    (2)#yum install g++

    如果不做这些后面就好像不能继续了。

  (3)登陆下面四个网站把东西下载好,一共有四个文件

  http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.bz2  ftp://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.bz2    http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2    http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz

  (4)把四个文件分别解压

  [root@localhost gcc]# tar -zxvf gcc-4.8.1.tar.gz
  [root@localhost gcc]# tar -zxvf mpc-0.8.1.tar.gz 
  [root@localhost gcc]# tar -jxvf gmp-4.3.2.tar.bz2 
  [root@localhost gcc]# tar -jxvf mpfr-2.4.2.tar.bz2 

  (5)可以放在一起编译,解压好的都放在一个文件夹里面

  cd gcc-4.8.1/  mv gmp-4.3.2 gcc-4.8.1/gmp  mv mpfr-2.4.2 gcc-4.8.1/mpfr  mv mpc-0.8.1 gcc-4.8.1/mpc

  (6)建立一个新目录,并且进入新目录中

[root@localhost gcc]# mkdir gcc-build-4.8.1[root@localhost gcc]# cd gcc-build-4.8.1/[root@localhost gcc-build-4.8.1]# 

   (7) configure命令:

../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib

  (8)编译

#make -j4

  这个过程等了我很长时间差不多有半个小时吧

  (9) 安装

#make install

  等完成之后终于可以结束了!!

通过以下语句检查版本:

[root@localhost gcc-build-4.8.1]# g++ --versiong++ (GCC) 4.8.1Copyright (C) 2013 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表