GLIBCXX_3.4.21' not found问题小记

问题描述:

mysql启动时报错:

/bin/mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /bin/mysqld)

Connection closed by foreign host.lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /bin/mysqld)

问题排查:

1、系统中查找libstdc++.so.6,发现为一个软连接

/usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.19

2、查看符号

[root@localhost src]# 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_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH

确认缺失GLIBCXX_3.4.20,GLIBCXX_3.4.21,需升级libstdc++库,未找到更高版本rpm安装包。需编译gcc5.4.0以上版本,生成libstdc++.so.6.0.20

3、下载系统安装镜像,配置yum本地源。方便工具包安装。

4、安装工具包

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

5、下载并离线编译gcc5.4.0

下载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_prerequisits
mkdir build
cd build
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make 

遇到问题:

1、执行./contrib/download_prerequisits时需远程下载gmp,mpc,mpfr,由于环境特殊,不能连接外网,所以暂未运行此脚本,直接进行之后操作时报错:

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

自行下载gmp,mpc,mpfr源码编译,arm平台报错无法识别aarch64架构。

查看download_prerequisits脚本,以下为此脚本内容:

# 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

手动下载mpfr-2.4.2.tar.bz2,gmp-4.3.2.tar.bz2,mpc-0.8.1.tar.bz2并做软链接。

之后再进行configure等操作,gcc可以进行编译。

等待编译完成后查找libstdc++.so.6.0.20,这里找到库版本为libstdc++.so.6.0.21,查看符号确认存在GLIBCXX_3.4.20,GLIBCXX_3.4.21.

拷贝libstdc++.so.6.0.21到/usr/lib64/ 并建立新的软链接

rm /usr/lib64/libstdc++.so.6

ln -s /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.21

重新启动后无报错。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值