ubuntu 安装g++

安装g++ 首先得安装gcc,一般Ubuntu 系统都会自带gcc,但是却没有g++,所以g++还是需要手动安装。这里我通过安装包的方式安装。关于gcc的安装可以点击这里here,我的Ubuntu是14.04版本的,gcc是4.8.4版本,所以下载了g++4.8.4版本的,下载地址点击这里here,我将安装需要的安装包都放到了/home/wl/Desktop/g++/目录下

root@ubuntu:/home/wl/Desktop/g++# ll -h
total 19M
drwxr-xr-x 2 root root 4.0K Oct 27 11:55 ./
drwxr-xr-x 4 wl   wl   4.0K Oct 27 11:42 ../
-rw-r--r-- 1 root root  18M Oct 27 11:41 g++-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root 1.1M Oct 27 11:46 libstdc++-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb
-rw-r--r-- 1 root root 253K Oct 27 11:51 libstdc++6_4.8.4-2ubuntu1-14.04.3_amd64.deb
root@ubuntu:/home/wl/Desktop/g++# 

不多说开始安装

root@ubuntu:/usr/pcre/pcre-8.31# dpkg -i /home/wl/Desktop/g++/g++-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb        
Selecting previously unselected package g++-4.8.
(Reading database ... 165202 files and directories currently installed.)
Preparing to unpack .../g++-4.8_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking g++-4.8 (4.8.4-2ubuntu1~14.04.3) ...
dpkg: dependency problems prevent configuration of g++-4.8:
 g++-4.8 depends on libstdc++-4.8-dev (= 4.8.4-2ubuntu1~14.04.3); however:
  Package libstdc++-4.8-dev is not installed.

dpkg: error processing package g++-4.8 (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
 g++-4.8
root@ubuntu:/usr/pcre/pcre-8.31#

报错了 : Package libstdc++-4.8-dev is not installed. 安装 libstdc++-4.8-dev

root@ubuntu:/usr/pcre/pcre-8.31# dpkg -i /home/wl/Desktop/g++/libstdc++-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb 
Selecting previously unselected package libstdc++-4.8-dev:amd64.
(Reading database ... 165241 files and directories currently installed.)
Preparing to unpack .../libstdc++-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libstdc++-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) ...
dpkg: dependency problems prevent configuration of libstdc++-4.8-dev:amd64:
 libstdc++-4.8-dev:amd64 depends on libstdc++6 (>= 4.8.4-2ubuntu1~14.04.3); however:
  Version of libstdc++6:amd64 on system is 4.8.2-19ubuntu1.

dpkg: error processing package libstdc++-4.8-dev:amd64 (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 libstdc++-4.8-dev:amd64
root@ubuntu:/usr/pcre/pcre-8.31# 

报错:Version of libstdc++6:amd64 on system is 4.8.2-19ubuntu1 版本不够高,安装需要的版本

root@ubuntu:/usr/pcre/pcre-8.31# dpkg -i /home/wl/Desktop/g++/libstdc++6_4.8.4-2ubuntu1-14.04.3_amd64.deb        
(Reading database ... 165977 files and directories currently installed.)
Preparing to unpack .../libstdc++6_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libstdc++6:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libstdc++6:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
root@ubuntu:/usr/pcre/pcre-8.31# 

成功 再次安装libstdc++-4.8-dev

root@ubuntu:/usr/pcre/pcre-8.31# dpkg -i /home/wl/Desktop/g++/libstdc++-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb 
(Reading database ... 165989 files and directories currently installed.)
Preparing to unpack .../libstdc++-4.8-dev_4.8.4-2ubuntu1-14.04.3_amd64.deb ...
Unpacking libstdc++-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.4-2ubuntu1~14.04.3) ...
Setting up libstdc++-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) ...
root@ubuntu:/usr/pcre/pcre-8.31# 

成功 最后安装 g++-4.8.4

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

成功,查看g++ 版本

root@ubuntu:/usr/pcre/pcre-8.31# g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@ubuntu:/usr/pcre/pcre-8.31# 

本文中用到的安装包下载地址

猜你喜欢

转载自blog.csdn.net/name_is_wl/article/details/52945118