2022-10-10 没有root权限怎么解决GLIBCXX版本太低的问题 / gcc与GLIBCXX的版本对应

libstdc++.so.6: version `GLIBCXX_2.17' not found

原来是因为服务器的gcc版本太低,所以需要升级gcc,可是又没有root权限,没办法用yum来直接把相关的依赖包全部装好,只能去下载源码来一个一个编译安装。
需要安装先后顺序:gmp、mpfr、mpc、gcc 这四个库。[链接](Index of /gnu/gmp/ (ustc.edu.cn)
)

./configure --prefix=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2
make
make install

./configure --prefix=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpfr-2.4.2 --with-gmp-include=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/include --with-gmp-lib=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/lib
make
make install

./configure --prefix=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpc-1.0.1 --with-gmp-include=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/include --with-gmp-lib=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/lib --with-mpfr-include=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpfr-2.4.2/include --with-mpfr-lib=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpfr-2.4.2/lib
make
make install

./configure --prefix=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gcc-4.7.2 --with-gmp-include=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/include --with-gmp-lib=/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/lib --with-mpfr-include=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpfr-2.4.2/include --with-mpfr-lib=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpfr-2.4.2/lib --with-mpc-include=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpc-1.0.1/include --with-mpc-lib=/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpc-1.0.1/lib
make
make install

image.png

修改~/.bashrc,添加PATH和LD_LIBRARY_PATH

export PATH=装gcc的路径里的/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
export LD_LIBRARY_PATH=装gcc的路径里的/usr/local/lib64:$LD_LIBRARY_PATH

错误排除:

*** LIBRARY_PATH shouldn‘t contain the current directory when *** building gcc.

image.png

方法一:
重新export LIBRARY_PATH和C_INCLUDE_PATH 尾部不含冒号
方法二:

export LIBRARY_PATH=$(echo $LIBRARY_PATH | sed 's/:$//; s/^://;')
export C_INCLUDE_PATH=$(echo $C_INCLUDE_PATH | sed 's/:$//; s/^://;')

configure: error: cannot compute suffix of object files: cannot compile

image.png

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpc-1.0.1/lib:/public1/home/stu_wanbeiyuan/software/glibc-2.27/gmp-4.3.2/lib:/public1/home/stu_wanbeiyuan/software/glibc-2.27/mpfr-2.4.2/lib

/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory

新编译出来的程序无法在64位系统下运行,需要安装
(没有root, 有待解决。。。。。。)

yum install glibc-devel.i686 libstdc++-devel.i686

你可能感兴趣的:(2022-10-10 没有root权限怎么解决GLIBCXX版本太低的问题 / gcc与GLIBCXX的版本对应)