GCC 安装 (Linux + 非root)

非root用户安装于cuda版本相对应的gcc

降低或升高服务器上的GCC版本
报错:configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+

安装依赖库

按顺序下载和安装依赖库

下载

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2      
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz

安装gmp

tar -jxvf gmp-6.1.0.tar.bz2
cd gmp-6.1.0
mkdir my-install
cd my-install
../configure --prefix=/home/p289796/lib/gmp-6.1.0/my-install
make && make install

安装mpfr

tar -jxvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
mkdir my-install
cd my-install
../configure --prefix=/home/p289796/lib/mpfr-3.1.4/my-install --with-gmp=/home/p289796/lib/gmp-6.1.0/my-install
make && make install

安装mpc

tar -zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
mkdir my-install
cd my-install
../configure --prefix=/home/p289796/lib/mpc-1.0.3/my-install --with-mpfr=/home/p289796/lib/mpfr-3.1.4/my-install --with-gmp=/home/p289796/lib/gmp-6.1.0/my-install
make && make install

GCC 安装

wget https://ftp.gnu.org/gnu/gcc/gcc-9.4.0/gcc-9.4.0.tar.gz
tar -xzvf gcc-9.4.0.tar.gz
cd gcc-9.4.0
mkdir my-compile my-install
cd my-compile
../configure --prefix=/home/p289796/compiler/gcc-9.4.0/my-install --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++,fortran --with-gmp=/home/p289796/lib/gmp-6.1.0/my-install --with-mpfr=/home/p289796/lib/mpfr-3.1.4/my-install --with-mpc=/home/p289796/lib/mpc-1.0.3/my-install
make -j4
make install

添加环境变量

#vim ~/.bashrc
export LD_LIBRARY_PATH=/home/p289796/compiler/gcc-9.4.0/my-install/lib64:$LD_LIBRARY_PATH
export PATH=/home/p289796/compiler/gcc-9.4.0/my-install/bin:$PATH
#source ~/.bashrc
gcc --version

你可能感兴趣的:(GCC,g++,非root)