mysql编译安装gcc_CentOS 7 源码编译安装高版本gcc

在编译MySQL 8.0 时,提示GCC版本过低(4.8.5),需要升级GCC到5.3及以上版本,按照网上教程,源码编译GCC 9.2.0版本,虽然遇到一点问题,不过总算顺利通过,记录一下GCC源码编译过程。

环境:

操作系统:CentOS 7.2

GCC版本:9.2.0

一、下载GCC源码

这里以安装gcc 9.2.0版本为例。

1. 下载gcc源码:

wget http://mirror.hust.edu.cn/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz

2. 解压:

tar xf gcc-9.2.0.tar.gz

3. 下载依赖包

cd gcc-9.2.0

./contrib/download_prerequisites

如果上述这一步卡住,无反应,可以考虑手动下载依赖包到GCC源码根目录。如下:

wget http://ftp.gnu.org/pub/gnu/gmp/gmp-6.1.0.tar.bz2

wget http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2

wget http://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz

wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2

再次执行:

./contrib/download_prerequisites --no-verify

解压gmp-6.1.0.tar.bz2这个文件时,会报错,如下:

bzip2: Compressed file ends unexpectedly;

perhaps it is corrupted? *Possible* reason follows.

bzip2: Inappropriate ioctl for device

Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.

You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover

data from undamaged sections of corrupted files.

tar: Child returned status 2

tar: Error is not recoverable: exiting now

看起来像是bzip2的Bug,在windows上用rar解压没有问题,这里直接把windows上解压的目录拷贝到CentOS GCC源码根目录下解决。

再次执行:

./contrib/download_prerequisites --no-verify

运行成功,如下:

All prerequisites downloaded successfully.

二、编译源码

配置编译选项:

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

编译:

make

报错:

makeinfo: command not found

安装texinfo:

yum install perl-Text-Unidecode

yum install perl-libintl

yum install texinfo

然后再次执行:

make

这个过程会持续很长时间,大约2~3个小时。(1核1G的虚拟机)

安装:

make install

验证gcc版本:

cd /usr/local/bin/

./gcc --version

gcc (GCC) 9.2.0

Copyright (C) 2019 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.

gcc 9.2.0 版本编译成功完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值