Centos compile and install gcc8.1

gcc has been upgraded to 8.1, try compiling it.

The latest version as of 2018-05-03: https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.1.0/gcc-8.1.0.tar.gz

Find more versions: http://ftp.gnu.org/gnu/gcc/

In addition, you can refer to the Tsinghua mirror, although it is not complete, but the speed is fast: https://mirrors.tuna.tsinghua.edu.cn/gnu

Install the basic build environment

yum install -y glibc-devel bison flex texinfo build-essential

#gcc gcc-c++ make

Download dependency library

./contrib/download_prerequisites

The ftp protocol is used by default, and the download may fail. Consider http download. https://gcc.gnu.org/pub/gcc/infrastructure/

Download dependencies according to the prompts, pay attention to the version number that prompts failure:

wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpc/mpc-1.0.3.tar.gz
tar xvfz mpc-1.0.3.tar.gz
ln -s mpc-1.0.3 mpc

wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gmp/gmp-6.1.0.tar.bz2

tar xvfj gmp-6.1.0.tar.bz2
ln -s gmp-6.1.0 gmp

wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpfr/mpfr-3.1.4.tar.bz2

tar xvfj mpfr-3.1.4.tar.bz2
ln -s mpfr-3.1.4 mpfr

# 还有一个 isl-0.18.tar.bz2 清华镜像中没有
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2

tar xvfj isl-0.18.tar.bz2
ln -s isl-0.18 isl

Create build directory

mkdir gcc-build; cd $_

Generate Makefile

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

Compile (note: this step is very time-consuming, I spent 203 minutes in the virtual machine)

make -j4

The -j4 option is make's optimization for multi-core processors. If it fails, try to remove this parameter.

Install

make install

After finishing, remember to log out and log in and refresh the profile again, or manually refresh:

source /etc/profile

check:

[root@localhost gcc-build]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/8.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
Thread model: posix
gcc version 8.1.0 (GCC)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325253211&siteId=291194637