Linux修改gcc版本(从5.4.0修改到4.8.0)

ubuntu下修改gcc版本,从5.4.0修改到8.2

问题描述:gcc8.2不是gcc的稳定版本,不能通过apt-get install 安装

 

解决方法:用下面命令安装,从源码编译

# 1. 下载gcc8.2的源码,源码编译 
   wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.gz && \
    tar xzvf gcc-8.2.0.tar.gz  && \
    cd gcc-8.2.0/   &&\
    wget http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/gmp-6.1.0.tar.bz2  && \
    wget http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/mpc-1.0.3.tar.gz  && \
    wget http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/mpfr-3.1.4.tar.bz2 && \
    wget http://ftp.tsukuba.wide.ad.jp/software/gcc/infrastructure/isl-0.18.tar.bz2 && \
    tar -jxvf gmp-6.1.0.tar.bz2 &&  ln -s gmp-6.1.0/ gmp && \
    tar -xzvf mpc-1.0.3.tar.gz  && ln -s mpc-1.0.3/ mpc && \
    tar -jxvf mpfr-3.1.4.tar.bz2 && ln -s mpfr-3.1.4/ mpfr && \
    tar -jxvf isl-0.18.tar.bz2 && ln -s isl-0.18/ isl && \
    cd ../ && mkdir gcc-bulid  && cd gcc-bulid/ && \
    ../gcc-8.2.0/configure CFLAGS="-g3 -gdwarf-2 -O0" CXXFLAGS="-g3 -gdwarf-2 -O0" CFLAGS_FOR_TARGET="-g3  -gdwarf-2 -O0" CXXFLAGS_FOR_TARGET="-g3 -gdwarf-2 -O0" --disable-multilib --enable-languages=c,c++ --prefix=/usr/local/gcc-8.2 && \
    make -j 4 && make install
# 2、修改gcc软链接
rm gcc
rm g++
ln -s /usr/local/gcc-8.2/bin/gcc /usr/local/bin/gcc
ln -s /usr/local/gcc-8.2/bin/g++ /usr/local/bin/g++
ln -s /usr/local/gcc-8.2/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-8.2/bin/g++ /usr/bin/g++
echo "PATH=/usr/local/gcc-8.2/bin:$PATH" > ~/.bashrc
sources ~/.bashrc 

 

你可能感兴趣的:(Linux系统与嵌入式)