在创建达梦数据库时报/DMDB/bin/libsnappy.so: /lib64/libstdc++.so.6:version 'GLIBCXX_3.4.21' not foud

一、问题描述:

部署环境:
硬件:华为泰山200服务器(arm架构)
操作系统:中标麒麟7.6
数据库:达梦8

问题:在创建数据库时报/DMDB/bin/libsnappy.so: /lib64/libstdc++.so.6:version 'GLIBCXX_3.4.21' not foud(required by /DMDB/bin/libsnaapy.so)

问题截图:

 

 


原因:编译环境的gcc版本与可执行文件运行环境运行的gcc版本不匹配导致,如果编译环境的gcc版本过高或者过低,则会造成此种运行报错。


二、解决过程:
1.gcc -v 查看编译环境的gcc版本是否高于程序运行环境的gcc版本;
[root@localhost ~]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-neokylin-linux/4.8.5/lto-wrapper
目标:aarch64-neokylin-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.cs2c.com.cn/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-aarch64-neokylin-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-aarch64-neokylin-linux/cloog-install --enable-gnu-indirect-function --build=aarch64-neokylin-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (NeoKylin 4.8.5-36) (GCC)
[root@localhost ~]#

2.查看可执行文件运行环境/libstdc++.so.6中GLIBCXX的版本;
[root@localhost ~]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC
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_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBC_2.17
GLIBCXX_DEBUG_MESSAGE_LENGTH
[root@localhost ~]#
可以看到当前gcc4.8.5版本没有GLIBCXX_3.4.21

3.升级gcc到5.4
安装所需工具:

yum groupinstall "Development Tools"
yum install glibc-static libstdc++-static


下载gcc:http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/

tar -xvf gcc-5.4.0.tar.bz2
cd gcc-5.4.0
./contrib/download_prerequisites

注:
[root@localhost gcc-5.4.0]# ./contrib/download_prerequisites
--2020-06-14 10:45:01--  ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
           => “mpfr-2.4.2.tar.bz2”
正在解析主机 gcc.gnu.org (gcc.gnu.org)... 8.43.85.97, 2620:52:3:1:0:246e:9693:128c
正在连接 gcc.gnu.org (gcc.gnu.org)|8.43.85.97|:21... 失败:连接超时。
正在连接 gcc.gnu.org (gcc.gnu.org)|2620:52:3:1:0:246e:9693:128c|:21... 失败:网络不可达。

执行以上命令报错原因为网络不通或者没有配置wget,可以使用其他机器进行下载相关介质。
download_prerequisites内容为:
[root@localhost contrib]# cat download_prerequisites
#! /bin/sh

# Download some prerequisites needed by gcc.
# Run this from the top level of the gcc source tree and the gcc
# build will do the right thing.
#
# (C) 2010 Free Software Foundation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.

# If you want to disable Graphite loop optimizations while building GCC,
# DO NOT set GRAPHITE_LOOP_OPT as yes so that the ISL package will not
# be downloaded.
GRAPHITE_LOOP_OPT=yes

if [ ! -e gcc/BASE-VER ] ; then
        echo "You must run this script in the top level GCC source directory."
        exit 1
fi

# Necessary to build GCC.
MPFR=mpfr-2.4.2
GMP=gmp-4.3.2
MPC=mpc-0.8.1

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1
tar xjf $MPFR.tar.bz2 || exit 1
ln -sf $MPFR mpfr || exit 1

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1
tar xjf $GMP.tar.bz2  || exit 1
ln -sf $GMP gmp || exit 1

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1
tar xzf $MPC.tar.gz || exit 1
ln -sf $MPC mpc || exit 1

# Necessary to build GCC with the Graphite loop optimizations.
if [ "$GRAPHITE_LOOP_OPT" = "yes" ] ; then
  ISL=isl-0.14

  wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$ISL.tar.bz2 || exit 1
  tar xjf $ISL.tar.bz2  || exit 1
  ln -sf $ISL isl || exit 1
fi

可以将4个需要下载的介质下载完毕后放到gcc-5.4.0目录中并授予执行权限,然后将download_prerequisites中的wget开头的命令注释掉。
[root@localhost gcc-5.4.0]# chmod 777 gmp-4.3.2.tar.bz2 isl-0.14.tar.bz2 mpc-0.8.1.tar.gz mpfr-2.4.2.tar.bz2

[root@localhost contrib]# vi download_prerequisites
#! /bin/sh

# Download some prerequisites needed by gcc.
# Run this from the top level of the gcc source tree and the gcc
# build will do the right thing.
#
# (C) 2010 Free Software Foundation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.

# If you want to disable Graphite loop optimizations while building GCC,
# DO NOT set GRAPHITE_LOOP_OPT as yes so that the ISL package will not
# be downloaded.
GRAPHITE_LOOP_OPT=yes

if [ ! -e gcc/BASE-VER ] ; then
        echo "You must run this script in the top level GCC source directory."
        exit 1
fi

# Necessary to build GCC.
MPFR=mpfr-2.4.2
GMP=gmp-4.3.2
MPC=mpc-0.8.1

#wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPFR.tar.bz2 || exit 1
tar xjf $MPFR.tar.bz2 || exit 1
ln -sf $MPFR mpfr || exit 1

#wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$GMP.tar.bz2 || exit 1
tar xjf $GMP.tar.bz2  || exit 1
ln -sf $GMP gmp || exit 1

#wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$MPC.tar.gz || exit 1
tar xzf $MPC.tar.gz || exit 1
ln -sf $MPC mpc || exit 1

# Necessary to build GCC with the Graphite loop optimizations.
if [ "$GRAPHITE_LOOP_OPT" = "yes" ] ; then
  ISL=isl-0.14

  #wget ftp://gcc.gnu.org/pub/gcc/infrastructure/$ISL.tar.bz2 || exit 1
  tar xjf $ISL.tar.bz2  || exit 1
  ln -sf $ISL isl || exit 1
fi

再次执行以下命令:
[root@localhost gcc-5.4.0]# ./contrib/download_prerequisites

mkdir build

cd build

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

make && make install

安装完了重启电脑。
解决’GLIBCXX_3.4.21’ not found

cp /usr/local/lib64/libstdc++.so.6.0.21 /lib64
cd /lib64
rm -rf libstdc++.so.6
ln -s libstdc++.so.6.0.21 libstdc++.so.6


执行以下命令来查看’GLIBCXX_3.4.21’

strings /lib64/libstdc++.so.6 | grep GLIBC


[root@localhost ~]# strings /lib64/libstdc++.so.6 | grep GLIBC
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_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBC_2.17
GLIBCXX_DEBUG_MESSAGE_LENGTH
_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv@GLIBCXX_3.4
nanosleep@@GLIBC_2.17
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv@@GLIBCXX_3.4.5
pthread_mutex_lock@@GLIBC_2.17
fdopen@@GLIBC_2.17
lseek64@@GLIBC_2.17
_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw@GLIBCXX_3.4
__strtod_l@@GLIBC_2.17
__newlocale@@GLIBC_2.17
_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv@@GLIBCXX_3.4.5
clock_gettime@@GLIBC_2.17
GLIBCXX_3.4.21
strtold_l@@GLIBC_2.17
bind_textdomain_codeset@@GLIBC_2.17
fileno@@GLIBC_2.17
wctob@@GLIBC_2.17
mbsrtowcs@@GLIBC_2.17
__strtof_l@@GLIBC_2.17
GLIBCXX_3.4.9
_ZSt10adopt_lock@@GLIBCXX_3.4.11
pthread_cond_broadcast@@GLIBC_2.17
GLIBCXX_3.4.10
GLIBCXX_3.4.16
__strcoll_l@@GLIBC_2.17
GLIBCXX_3.4.1
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv@GLIBCXX_3.4
__strxfrm_l@@GLIBC_2.17
_ZNSs7_M_copyEPcPKcm@GLIBCXX_3.4
stdout@@GLIBC_2.17
fread@@GLIBC_2.17
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv@@GLIBCXX_3.4.5
_ZNSs7_M_moveEPcPKcm@@GLIBCXX_3.4.5
_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv@GLIBCXX_3.4
realloc@@GLIBC_2.17
_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv@GLIBCXX_3.4
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEm@@GLIBCXX_3.4.5
_ZNSs4_Rep26_M_set_length_and_sharableEm@GLIBCXX_3.4
_ZSt10defer_lock@@GLIBCXX_3.4.11
__towlower_l@@GLIBC_2.17
__cxa_atexit@@GLIBC_2.17
__cxa_finalize@@GLIBC_2.17
_ZN10__gnu_norm15_List_node_base4swapERS0_S1_@@GLIBCXX_3.4
_ZNSs9_M_assignEPcmc@@GLIBCXX_3.4.5
get_nprocs@@GLIBC_2.17
_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEmmPKc@@GLIBCXX_3.4.5
_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv@@GLIBCXX_3.4.5
__freelocale@@GLIBC_2.17
_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwm@GLIBCXX_3.4
_ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order@@GLIBCXX_3.4.11
fputc@@GLIBC_2.17
GLIBCXX_3.4.20
frexpl@@GLIBC_2.17
strncmp@@GLIBC_2.17
mbrtowc@@GLIBC_2.17
stderr@@GLIBC_2.17
_ZNSt11char_traitsIwE2eqERKwS2_@@GLIBCXX_3.4.5
GLIBCXX_3.4.12
abort@@GLIBC_2.17
_ZNSi6ignoreEv@@GLIBCXX_3.4.5
GLIBCXX_3.4.2
__wcsxfrm_l@@GLIBC_2.17
_ZNSt11char_traitsIcE2eqERKcS2_@@GLIBCXX_3.4.5
GLIBCXX_3.4.6
wmemcpy@@GLIBC_2.17
GLIBCXX_3.4.15
_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv@@GLIBCXX_3.4.5
_ZNSs9_M_assignEPcmc@GLIBCXX_3.4
GLIBCXX_3.4.19
fflush@@GLIBC_2.17
_ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv@GLIBCXX_3.4
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv@GLIBCXX_3.4
__fxstat64@@GLIBC_2.17
__assert_fail@@GLIBC_2.17
isalnum@@GLIBC_2.17
writev@@GLIBC_2.17
_ZN10__gnu_norm15_List_node_base7reverseEv@@GLIBCXX_3.4
__errno_location@@GLIBC_2.17
stdin@@GLIBC_2.17
wmemchr@@GLIBC_2.17
pthread_cond_wait@@GLIBC_2.17
syscall@@GLIBC_2.17
setlocale@@GLIBC_2.17
fopen@@GLIBC_2.17
wcrtomb@@GLIBC_2.17
mbsnrtowcs@@GLIBC_2.17
_ZN10__gnu_norm15_List_node_base4hookEPS0_@@GLIBCXX_3.4
wcslen@@GLIBC_2.17
pthread_cond_destroy@@GLIBC_2.17
_ZNSt11char_traitsIwE2eqERKwS2_@GLIBCXX_3.4
_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwm@GLIBCXX_3.4
_ZNSbIwSt11char_traitsIwESaIwEE7_M_copyEPwPKwm@@GLIBCXX_3.4.5
poll@@GLIBC_2.17
malloc@@GLIBC_2.17
GLIBCXX_3.4.3
GLIBCXX_3.4.7
wmemcmp@@GLIBC_2.17
_ZNSi6ignoreEl@@GLIBCXX_3.4.5
isspace@@GLIBC_2.17
_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw@@GLIBCXX_3.4.5
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv@GLIBCXX_3.4
_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv@@GLIBCXX_3.4.5
__strftime_l@@GLIBC_2.17
_ZNSbIwSt11char_traitsIwESaIwEE7_M_moveEPwPKwm@@GLIBCXX_3.4.5
putwc@@GLIBC_2.17
GLIBCXX_3.4.18
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEm@GLIBCXX_3.4
fclose@@GLIBC_2.17
pthread_cond_signal@@GLIBC_2.17
ioctl@@GLIBC_2.17
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEl@@GLIBCXX_3.4.5
__duplocale@@GLIBC_2.17
_ZSt15future_category@@GLIBCXX_3.4.14
strtoul@@GLIBC_2.17
setvbuf@@GLIBC_2.17
_ZNSi6ignoreEl@GLIBCXX_3.4
fseeko64@@GLIBC_2.17
pthread_mutex_unlock@@GLIBC_2.17
strcmp@@GLIBC_2.17
_ZNSt11char_traitsIcE2eqERKcS2_@GLIBCXX_3.4
__towupper_l@@GLIBC_2.17
_ZNKSs15_M_check_lengthEmmPKc@GLIBCXX_3.4
_ZN10__gnu_norm15_List_node_base8transferEPS0_S1_@@GLIBCXX_3.4
getenv@@GLIBC_2.17
vsnprintf@@GLIBC_2.17
_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwmw@GLIBCXX_3.4
gettimeofday@@GLIBC_2.17
_ZNVSt9__atomic011atomic_flag5clearESt12memory_order@@GLIBCXX_3.4.11
_ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv@@GLIBCXX_3.4.5
__wcscoll_l@@GLIBC_2.17
strchr@@GLIBC_2.17
__uselocale@@GLIBC_2.17
_ZNKSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv@GLIBCXX_3.4
_ZNSs7_M_moveEPcPKcm@GLIBCXX_3.4
ftello64@@GLIBC_2.17
wmemset@@GLIBC_2.17
bindtextdomain@@GLIBC_2.17
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEl@GLIBCXX_3.4
btowc@@GLIBC_2.17
ungetwc@@GLIBC_2.17
_ZNSbIwSt11char_traitsIwESaIwEE9_M_assignEPwmw@@GLIBCXX_3.4.5
_ZNKSbIwSt11char_traitsIwESaIwEE15_M_check_lengthEmmPKc@GLIBCXX_3.4
_ZNKSs11_M_disjunctEPKc@@GLIBCXX_3.4.5
wcscmp@@GLIBC_2.17
_ZN10__gnu_norm15_List_node_base6unhookEv@@GLIBCXX_3.4
free@@GLIBC_2.17
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv@@GLIBCXX_3.4.5
_ZNSi6ignoreEv@GLIBCXX_3.4
strerror@@GLIBC_2.17
sprintf@@GLIBC_2.17
_ZNSs7_M_copyEPcPKcm@@GLIBCXX_3.4.5
__wctype_l@@GLIBC_2.17
fwrite@@GLIBC_2.17
__ctype_get_mb_cur_max@@GLIBC_2.17
wmemmove@@GLIBC_2.17
GLIBCXX_3.4.8
fputs@@GLIBC_2.17
GLIBCXX_3.4.13
_ZSt11try_to_lock@@GLIBCXX_3.4.11
_ZNKSt14basic_ofstreamIwSt11char_traitsIwEE7is_openEv@@GLIBCXX_3.4.5
wcsnrtombs@@GLIBC_2.17
GLIBCXX_3.4.17
GLIBCXX_3.4.4
_ZNKSs15_M_check_lengthEmmPKc@@GLIBCXX_3.4.5
strlen@@GLIBC_2.17
_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv@GLIBCXX_3.4
fopen64@@GLIBC_2.17
ungetc@@GLIBC_2.17
__iswctype_l@@GLIBC_2.17
_ZNSs4_Rep26_M_set_length_and_sharableEm@@GLIBCXX_3.4.5
__nl_langinfo_l@@GLIBC_2.17
dgettext@@GLIBC_2.17
_ZNKSs11_M_disjunctEPKc@GLIBCXX_3.4
__wcsftime_l@@GLIBC_2.17
[root@localhost ~]#
 

glibc的版本太低,要先升级glibc,至少要升级到glibc3.4.21版本。
可以执行:ldd --version 查看你当前的glibc版本,应该是低于3.4.21版本的。