libstdc++.so.6 version GLIBCXX_3.4.19 not found

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010736419/article/details/80063486

RHEL系统中,编译一些软件会出现libstdc++.so.6version 'GLIBCXX_3.4.19' not found的报错,错误出现的原因是因为操作系统版本太低了,需要对一些插件进行升级。

[root@bogon build]# strings/usr/lib64/libstdc++.so.6|grep GLIBCXX

GLIBCXX_3.4

GLIBCXX_3.4.1

GLIBCXX_3.4.2

GLIBCXX_3.4.3

GLIBCXX_3.4.4

GLIBCXX_3.4.5

GLIBCXX_3.4.6

GLIBCXX_3.4.7

GLIBCXX_3.4.8

GLIBCXX_3.4.9

GLIBCXX_3.4.10

GLIBCXX_3.4.11

GLIBCXX_3.4.12

GLIBCXX_3.4.13

GLIBCXX_FORCE_NEW

GLIBCXX_DEBUG_MESSAGE_LENGTH

可看出,最高支持的版本为GLIBCXX_3.4.13

升级gcc,下载6.2.0 版本:

参考:https://blog.csdn.net/sparkexpert/article/details/56489639

wget http://ftpmirror.gnu.org/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2

gcc安装文件下载完成后,执行以下命令解压文件:

tar -xfgcc-6.2.0.tar.bz2

解压完成后,执行以下命令进入工作目录:

cdgcc-6.2.0

执行download_prerequisites脚本,下载gcc依赖文件和库:

修改为:

wgethttp://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2 || exit 1

tar xjf$MPFR.tar.bz2 || exit 1

ln -sf$MPFR mpfr || exit 1

wgethttps://gmplib.org/download/archive/gmp-4.2.3/gmp-4.2.3.tar.bz2 || exit 1

tar xjf$GMP.tar.bz2  || exit 1

ln -sf$GMP gmp || exit 1

wgethttp://www.multiprecision.org/downloads/mpc-0.8.1.tar.gz || exit 1

tar xzf$MPC.tar.gz || exit 1

ln -sf$MPC mpc || exit 1

# Necessaryto build GCC with the Graphite loop optimizations.

if ["$GRAPHITE_LOOP_OPT" = "yes" ] ; then

  ISL=isl-0.15

  wgethttp://isl.gforge.inria.fr/isl-0.15.tar.bz2 || exit 1

  tar xjf $ISL.tar.bz2  || exit 1

  # Fix trailing comma which errors with -pedanticfor host GCC <= 4.3

  sed -e 's/isl_stat_ok = 0,/isl_stat_ok = 0/'isl-0.15/include/isl/ctx.h > isl-0.15/include/isl/ctx.h.tem && mvisl-0.15/include/isl/ctx.h.tem isl-0.15/include/isl/ctx.h

  ln -sf $ISL isl || exit 1

fi

执行./contrib/download_prerequisites下载安装gcc所需的mpfr、gmp和mpc文件。

建立一个输出目录,编译时所有生成的中间文件都放到该目录下:

mkdirbuild

工作目录切换至输出目录,并在其中执行配置和安装:

cd build

执行configure配置安装文件:

../configure--enable-checking=release --enable-languages=c,c++ --disable-multilib

配置完成后,执行以下命令,编译gcc:

make -j 6

注意:编译gcc时间较长,可以多启用多个核数来执行。

编译完成后,安装gcc:

makeinstall

安装完成后还需要替换系统默认的gcc,执行以下命令,查找6.2版本的安装文件:

第二步:升级GLIBCXX

注意,进入GCC编译输出目录,.libs是隐藏的:build/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs

用下面的命令查看:

stringslibstdc++.so.6.0.22|grep GLIBCXX

一般来讲,里面就有满足需要的GLIBCXX版本了。

然后,把该文件拷贝到了/usr/lib64下.

然后将libstdc++.so.6指向libstdc++.so.6.0.22:

这一步一定要在ROOT权限下执行。

rm -rlibstdc++.so.6

rm:remove symbolic link `libstdc++.so.6'? y

ln -slibstdc++.so.6.0.18 libstdc++.so.6

这就Ok了。

升级最新版gcc

Gnc镜像地址:

http://www.gnu.org/prep/ftp.html

国内选择清华镜像:

https://mirrors.ustc.edu.cn/gnu/

下载gcc:

wget https://mirrors.ustc.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz

修改/contrib/download_prerequisites:修改baseurl为:

urld=('https://mirrors.ustc.edu.cn/gnu/gmp/''https://mirrors.ustc.edu.cn/gnu/mpfr/' 'https://mirrors.ustc.edu.cn/gnu/mpc/''http://isl.gforge.inria.fr/')

同时修改下载程序段:

n=0

for ar in $(echo_archives)

do

   if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi

    [-e "${directory}/${ar}" ]                                              \

       || ${fetch} --no-verbose -O "${directory}/${ar}""${urld[$n]}${ar}"       \

       || die "Cannot download ${ar} from ${base_url}"

   n=$[n+1]

done

其余过程与上面一致。

猜你喜欢

转载自blog.csdn.net/u010736419/article/details/80063486