centos8/7 非root安装gcc8.4.0, 解决gcc版本过低及libgfortran.so.5缺失问题
2021-07-29 19:57 丨o聽乄雨o丨 阅读(4657) 评论(0) 编辑 收藏 举报在非root环境下安装gcc-8.4.0,可以解决redhat/centos gcc版本过低导致的软件编译错误的问题。gcc-8.4.0需要一系列的依赖包。
1.下载依赖包:
gmp-6.2.0, mpfr-4.1.0, mpc-1.2.0, isl-0.18
可以从以下链接中下载
http://mirrors.nju.edu.cn/gnu/
下载结束后解压。
2.依次安装上述依赖包:
mkdir ~/usr/local/ (可以自定义安装目录)
cd gmp-6.2.0
./configure --prefix=~/usr/local/
make && make install
安装gmp-6.0依赖库
dnf/yum install gmp-devel-6.0.0-15.el7.x86_64 texinfo flex
cd mpfr-4.1.0
./configure --prefix=~/usr/local --with-gmp=~/usr/local
make && make install
cd mpc-1.2.0
./configure --prefix=~/usr/local --with-gmp=~/usr/local --with-mpfr=~/usr/local
make && make install
cd isl-0.18
./configure --prefix=~/usr/local --with-gmp=~/usr/local
make && make install
将上述依赖包的lib目录加入库搜索路径:
export LD_LIBRARY_PATH=~/usr/local/lib:$LD_LIBRARY_PATH
3. 下载解压安装gcc-8.4.0:
cd gcc-8.4.0
./configure --prefix=~/usr/local --with-gmp=~/usr/local --with-mpfr=~/usr/local --with-mpc=~/usr/local --enable-checkinf=release --enable-languages=c,c++,fortran --disable-multilib
make && make install
安装完成后将路径加入环境变量:
GCCHOME=~/usr/local
export PATH=$GCCHOME/bin:$PATH
export LD_LIBRARY_PATH=$GCCHOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$GCCHOME/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$GCCHOME/include:$LD_LIBRARY_PATH
4. 报错找不到libgfortran.so.5的问题
首先确认在configure gcc那一步加入--enable-languages=fortran,这样才能编译gfortran;
其次确认~/usr/local/lib64目录有没有libgfortran.so.5.0.0;
最后ln -s ~/usr/local/lib64/libgfortran.so.5.0.0 /usr/lib64/libgfortran.so.5
谢谢。
部分摘自:https://blog.csdn.net/life_NULL/article/details/113684776