ubuntu gcc与g++版本更新问题

ubuntu gcc与g++版本更新问题

近期使用ubuntu编译mt7682 openwrt源码,编译报错。
在这里插入图片描述
百度发现,gcc,g++版本太低,不支持c++11,4.7版本以后才会支持,现在是gcc version 4.6.3。现在下载version 4.8.0,所以要更新gcc g++版本

下载地址:点击这里

下载完成。
cd 解压后的目录
./configure
发现报错:

checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.

百度,说原因是缺少mpfr,gmp,mpc依赖,安装依赖文件即可。
分别下载依赖包:
mpc:点击这里
mpfr:点击这里
gmp:点击这里

安装顺序按照上述下载顺序,否则会有依赖问题的报错,其次,这三个文件文件版本之间差异可能也会导致安装失败。
笔者贴出我的安装版本,测试ok
在这里插入图片描述
安装方法一致:./configure; make; sudo make install

下面再次安装gcc-4.8.0版本
安装发现还是报错,我将上述三个文件重新安装了一次解决了gcc -4.8.0安装error问题。

1,./configure

./configure之前需要将上述安装的依赖的库添加到环境变量,上述依赖库在/usr/local/lib,否则./configure还是报错
在这里插入图片描述
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

至此Makefile就能生成了
在这里插入图片描述

2,make

又遇到error了
在这里插入图片描述
继续安装依赖文件

sudo apt-get install lib32ncurses5-dev

sudo apt-get install libc6-dev-i386

make

3,make install

安装成功
在这里插入图片描述

安装成功后,注意
在这里插入图片描述
注意:将x86_64-linux-gnu-g++软链接修改为g++ 4.8版本,再次编译openwrt就能成功了

最后添加一个插曲,下载xxx.tar.lz文件解压
安装 lzip
执行 lzip -d 文件名 会得到一个.tar文件后使用tar解压

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值