centos安装gcc 4.9.4 版本

系统:centos 7.6

因为在安装hyperf热加载时需要用到fswatch,安装fswatch需要gcc4.9以上的版本,但是系统自带的gcc只有4.8的版本,所以我们需要安装4.9的,这里我安装的是4.9.4的版本:

yum install -y gcc gcc-c++
#因为我有自带的gcc 所以不用安装,如果没有的话。需要先安装yum自带的gcc

安装好后安装gmp:

#使用阿里云的gun镜像下载
yum install -y m4
wget https://mirrors.aliyun.com/gnu/gmp/gmp-6.1.1.tar.bz2 tar -xvjf gmp-6.1.1.tar.bz2 cd gmp-6.1.1 ./configure --prefix=/usr/local/ && make && make install

安装mpfr

wget https://mirrors.aliyun.com/gnu/mpfr/mpfr-3.1.5.tar.gz
tar -zxvf mpfr-3.1.5.tar.gz
cd mpfr-3.1.5
./configure --prefix=/usr/local/ --with-gmp=/usr/local/ && make && make install

安装mpc

wget https://mirrors.aliyun.com/gnu/mpc/mpc-1.0.3.tar.gz
tar -zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=/usr/local/ --with-gmp=/usr/local/ --with-mpfr=/usr/local/
make && make install

安装gcc

wget https://mirrors.aliyun.com/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.gz
tar -zxvf gcc-4.9.4.tar.gz
cd gcc-4.9.4
./configure --prefix=/usr/local/gcc-4.9.4 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
make && make install

编译gcc总共大概要编译一个小时,编译好之后卸载原有的gcc:

yum remove gcc gcc-c++
ln -s /usr/local/gcc-4.9.4/bin/c++ /usr/bin/c++
ln -s /usr/local/gcc-4.9.4/bin/g++ /usr/bin/g++
ln -s /usr/local/gcc-4.9.4/bin/gcc /usr/bin/gcc

vim /etc/profile
LD_LIBRARY_PATH=/usr/local/gcc-4.9.4/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

source /etc/profile

 

至此gcc4.9.4安装完成!

posted @ 2024-01-14 09:22  来碗酒喝  阅读(136)  评论(0编辑  收藏  举报