Ubuntu 安装gcc

今天作死把ubuntu gcc给卸载了,按照网上的apt-get install build-essential一直报错 没有成功 索性就直接用 安装包安装了。我的Ubuntu是14.04版本的,gcc是4.8.2版本。上网查找 一直没有找到4.2.8版本的,有一个却没有下载地址 所以逼不得已 下载了一个4.8.4版本的,一安装各种的依赖文件版本不够高就开始报错了,所以有把依赖的所有文件给重装了一次。下面给出下载各种安装包的网站http://packages.ubuntu.com/trusty/gcc-4.8 里面不仅有gcc的安装包下载 还有各式各样的安装包以及源码下载, 而且各个安装包的依赖关系都明确注明,也可以下载安装,所以需要安装什么都可以在这里面找到。
不多说了进去一看就知道资源有多丰富了!现在来说说gcc的安装。我把我要安装的文件全部都放在了我的/home/wl/Desktop/gcc下 如下图
这里写图片描述

root@ubuntu:/home/wl/Desktop/gcc# ll -h
total 12M
drwxr-xr-x 2 root root 4.0K Oct 26 23:29 ./
drwxr-xr-x 3 wl   wl   4.0K Oct 26 22:28 ../
-rw-r--r-- 1 root root 4.4M Oct 26 22:30 cpp-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root  16K Oct 26 22:36 gcc-4.8-base_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root 4.9M Oct 26 21:04 gcc-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root  62K Oct 26 23:12 libasan0_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root 8.5K Oct 26 23:11 libatomic1_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root 1.7M Oct 26 22:55 libgcc-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root  23K Oct 26 23:06 libgomp1_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root  28K Oct 26 23:08 libitm1_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root 124K Oct 26 23:14 libquadmath0_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root  93K Oct 26 23:22 libtsan0_4.8.4-2ubuntu1-14.04.3_amd64.deb
root@ubuntu:/home/wl/Desktop/gcc# 

现在开始安装

root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/gcc-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../gcc-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking gcc-4.8 (4.8.4-2ubuntu1~14.04.3) over (4.8.4-2ubuntu1~14.04.3) ...
dpkg: dependency problems prevent configuration of gcc-4.8:
 gcc-4.8 depends on cpp-4.8 (= 4.8.4-2ubuntu1~14.04.3); however:
  Version of cpp-4.8 on system is 4.8.2-19ubuntu1.
 gcc-4.8 depends on gcc-4.8-base (= 4.8.4-2ubuntu1~14.04.3); however:
  Version of gcc-4.8-base:amd64 on system is 4.8.2-19ubuntu1.
 gcc-4.8 depends on libgcc-4.8-dev (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libgcc-4.8-dev:amd64 on system is 4.8.2-19ubuntu1.

dpkg: error processing package gcc-4.8 (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
 gcc-4.8
root@ubuntu:/sys/dev# 

报错 可以看到主要是cpp 、gcc-base 、libgcc 的版本低于gcc-4.8.4的版本要求 现在重新安装着3个依赖文件。先装 gcc-base 因为cpp 都依赖于他

gcc-4.8-base_4.8.4-2ubuntu1-14.04.3_amd64.deb  gcc-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb       
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/gcc-4.8-base_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../gcc-4.8-base_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking gcc-4.8-base:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up gcc-4.8-base:amd64 (4.8.4-2ubuntu1~14.04.3) ...
root@ubuntu:/sys/dev# 

ok 接着同样的安装剩余的两个 根据情况的不同 可能会出现不一样的依赖,要按照自己的实际情况安装

root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/cpp-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../cpp-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking cpp-4.8 (4.8.4-2ubuntu1~14.04.3) over (4.8.4-2ubuntu1~14.04.3) ...
Setting up cpp-4.8 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for man-db (2.6.7.1-1) ...
root@ubuntu:/sys/dev#

成功 接着 libgcc

root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libgcc-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libgcc-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libgcc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
dpkg: dependency problems prevent configuration of libgcc-4.8-dev:amd64:
 libgcc-4.8-dev:amd64 depends on libgomp1 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libgomp1:amd64 on system is 4.8.2-19ubuntu1.
 libgcc-4.8-dev:amd64 depends on libitm1 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libitm1:amd64 on system is 4.8.2-19ubuntu1.
 libgcc-4.8-dev:amd64 depends on libatomic1 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libatomic1:amd64 on system is 4.8.2-19ubuntu1.
 libgcc-4.8-dev:amd64 depends on libasan0 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libasan0:amd64 on system is 4.8.2-19ubuntu1.
 libgcc-4.8-dev:amd64 depends on libtsan0 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libtsan0:amd64 on system is 4.8.2-19ubuntu1.
 libgcc-4.8-dev:amd64 depends on libquadmath0 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libquadmath0:amd64 on system is 4.8.2-19ubuntu1.

dpkg: error processing package libgcc-4.8-dev:amd64 (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 libgcc-4.8-dev:amd64
root@ubuntu:/sys/dev#

报错了,libgcc也需要安装依赖文件 libgomp1、libitm1 、libatomic1、libasan0 、libtsan0 、libquadmath0 。知道要安装哪些依赖文件事情就 好办了,直接一鼓作气全部安装

root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libgomp1_4.8.4-2ubuntu1-14.04.3_amd64.deb       
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libgomp1_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libgomp1:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libgomp1:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/lib                                       
libgcc-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb  libgomp1_4.8.4-2ubuntu1-14.04.3_amd64.deb        libitm1_4.8.4-2ubuntu1-14.04.3_amd64.deb
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libitm1_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libitm1_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libitm1:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libitm1:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libatomic1_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libatomic1_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libatomic1:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libatomic1:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libasan0_4.8.4-2ubuntu1-14.04.3_amd64.deb   
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libasan0_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libasan0:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libasan0:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libquadmath0_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libquadmath0_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libquadmath0:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libquadmath0:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/sys/dev#dpkg -i /home/wl/Desktop/gcc/libtsan0_4.8.4-2ubuntu1-14.04.3_amd64.deb       
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libtsan0_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libtsan0:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libtsan0:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/libgcc-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../libgcc-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libgcc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.4-2ubuntu1~14.04.3) ...
Setting up libgcc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) 
root@ubuntu:/sys/dev# 

成功!最后安装 gcc-4.8.4

root@ubuntu:/sys/dev# dpkg -i /home/wl/Desktop/gcc/gcc-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../gcc-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb 

Unpacking gcc-4.8 (4.8.4-2ubuntu1~14.04.3) over (4.8.4-2ubuntu1~14.04.3) ...
Setting up gcc-4.8 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for man-db (2.6.7.1-1) ...
root@ubuntu:/sys/dev# 

完成 查看gcc 版本

root@ubuntu:/sys/dev# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
root@ubuntu:/sys/dev# `

大功告成–注意gcc装成功了但是g++并未安装成功。关于g++的安装可以参考gcc的安装。在http://packages.ubuntu.com/trusty/gcc-4.8网站中也可以找到g++的安装包,关于g++的安装会在另一篇博客中详细介绍
安装所需要的.dep文件压缩包下载地址

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值