背景
安装的操作系统:CentOS-7-x86_64-Everything-2009,安装好之后更新系统,尝试根据 https://github.com/coder/code-server的指引通过命令curl -fsSL https://code-server.dev/install.sh | sh
来安装code-server,安装过程没有报错,安装好之后尝试启动code-server报错:
version `GLIBC_2.27′ not found
查询网上资料显示是CentOS低版本系统的 GLIBC 版本过低,我们再查看 ldd 版本:
# ldd --version ldd (GNU libc) 2.17 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the sourcefor copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper.
我们发现系统中 GLIBC 版本仅为 17,而报错中显示我们缺失,25,27,28。而 GLIBC是向下兼容的,安装高版本的同时会安装低版本,所以我们只需要安装 GLIBC_2.28 即可
注意:如果有条件的话可以直接升级系统 CentOS 8,可以有效解决问题
解决方案
更新 glibc
cd wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz tar xf glibc-2.28.tar.gz cd glibc-2.28/ && mkdir build
升级 gcc、make
# 升级GCC(默认为4 升级为8) yum install -y centos-release-scl yum install -y devtoolset-8-gcc* mv /usr/bin/gcc /usr/bin/gcc-4.8.5 ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc mv /usr/bin/g++ /usr/bin/g++-4.8.5 ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++ # 升级 make(默认为3 升级为4) wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz tar -xzvf make-4.3.tar.gz &&cd make-4.3/ ./configure --prefix=/usr/local/make make && make install cd /usr/bin/ && mv make make.bak ln -sv /usr/local/make/bin/make /usr/bin/make
升级 libstdc++
yum whatprovides libstdc++.so.6 yum update -y libstdc++.x86_64 yum install -y libstdc++-4.8.5-44.el7.i686 wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip unzip libstdc.so_.6.0.26.zip cp libstdc++.so.6.0.26 /lib64/ cd /lib64 # 把原来的命令做备份 cp libstdc++.so.6 libstdc++.so.6.bak rm -f libstdc++.so.6 # 重新链接 ln -s libstdc++.so.6.0.26 libstdc++.so.6
编译安装
cd ~/glibc-2.28/build # 配置环境 ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin # 安装 make make install
查看版本
(base)[root@VM-4-3-centos build]# ldd --version ldd (GNU libc) 2.28 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the sourcefor copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper.
参考资料: