Glibc 版本 not found

glibc version not found

foreversmart write on 2020-07-22
glibc是GNU发布的libc库,即c运行库。glibc是linux系统中最底层的api,几乎其它任何运行库都会依赖于glibc。glibc除了封装linux操作系统所提供的系统服务外,它本身也提供了许多其它一些必要功能服务的实现。由于 glibc 囊括了几乎所有的 UNIX 通行的标准,可以想见其内容包罗万象。而就像其他的 UNIX 系统一样,其内含的档案群分散于系统的树状目录结构中,像一个支架一般撑起整个操作系统。
我们经常在运行一个程序的时候会发现对应的 Glibc 版本不对,例如下面的错误
/lib64/libc.so.6: version `GLIBC_2.28' not found (required by ./headscale)
Shell
产看当前 glibc 的版本
strings /lib64/libc.so.6 | grep GLIBC GLIBC_2.2.5 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3 GLIBC_2.3.4 GLIBC_2.4 GLIBC_2.5 GLIBC_2.6 GLIBC_2.7 GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 GLIBC_2.11 GLIBC_2.12 GLIBC_2.13 GLIBC_2.14 GLIBC_2.15 GLIBC_2.16 GLIBC_2.17 GLIBC_2.18 GLIBC_2.22 GLIBC_2.23 GLIBC_2.24 GLIBC_2.25 GLIBC_2.26 GLIBC_2.27 GLIBC_2.28 GLIBC_PRIVATE
Shell
源码下载:
各个版本的glibc可以从http://ftp.gnu.org/gnu/glibc/找,包括其插件glibc-port
编译安装:
/glibc-2.30 # mkdir build /glibc-2.30 # cd build /glibc-2.30 ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
Shell
这里注意可能会出现一些依赖版本的问题
checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for gcc... gcc checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for readelf... readelf checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking whether g++ can link programs... no checking for sysdeps preconfigure fragments... aarch64 alpha arm hppa i386 m68k microblaze mips nios2 powerpc riscv s390 sh sparc x86_64 checking whether gcc compiles in -mx32 mode by default... no checking for use of fpu sysdeps directories... yes checking for -fstack-protector... yes checking for -fstack-protector-strong... yes checking for -fstack-protector-all... yes checking for assembler and linker STT_GNU_IFUNC support... yes checking for gcc attribute ifunc support... yes checking if compiler warns about alias for function with incompatible types... no checking sysdep dirs... sysdeps/unix/sysv/linux/x86_64/64 sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86 sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64 sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64 sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86 sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754 sysdeps/generic checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking whether /usr/bin/as is GNU as... yes checking whether /usr/bin/ld is GNU ld... yes checking for /usr/bin/as... /usr/bin/as checking version of /usr/bin/as... 2.27, ok checking for /usr/bin/ld... /usr/bin/ld checking version of /usr/bin/ld... 2.27, ok checking for gnumake... no checking for gmake... gmake checking version of gmake... 3.82, bad checking for gnumsgfmt... no checking for gmsgfmt... no checking for msgfmt... msgfmt checking version of msgfmt... 0.19.8.1, ok checking for makeinfo... no checking for sed... sed checking version of sed... 4.2.2, ok checking for gawk... gawk checking version of gawk... 4.0.2, ok checking for bison... bison checking version of bison... 3.0.4, ok checking if gcc -B/usr/bin/ is sufficient to build libc... no checking for nm... nm checking for python3... python3 configure: error: *** These critical programs are missing or too old: make compiler *** Check the INSTALL file for required versions.
Shell
这个地方说我们的 make 版本太老
make -v GNU Make 3.82 Built for x86_64-redhat-linux-gnu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Shell
make 的版本确实有点太老
http://ftp.gnu.org/gnu/make/make-4.3.tar.gz 下载一个高版本的 make 源码进行编译安装
./configure make && make install #编译#安装 ln -s -f /usr/local/bin/make /usr/bin/make #必须运行该语句否则还是旧版本 make -version # 查看make版本 GNU Make 4.3 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Shell
可以看到已经成功的更新升级了 make 编译工具
上条命令执行成功后会在 build 目录下会生成一个 make 文件
在 build 下执行 make 进行安装操作
glibc-2.28/build/elf/pldd.o.dt -MT /root/temp/glibc-2.28/build/elf/pldd.o gcc -B/usr/bin/ -nostdlib -nostartfiles -o /root/temp/glibc-2.28/build/elf/pldd -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /root/temp/glibc-2.28/build/csu/crt1.o /root/temp/glibc-2.28/build/csu/crti.o `gcc -B/usr/bin/ --print-file-name=crtbegin.o` /root/temp/glibc-2.28/build/elf/pldd.o /root/temp/glibc-2.28/build/elf/xmalloc.o -Wl,-dynamic-linker=/lib64/ld-linux-x86-64.so.2 -Wl,-rpath-link=/root/temp/glibc-2.28/build:/root/temp/glibc-2.28/build/math:/root/temp/glibc-2.28/build/elf:/root/temp/glibc-2.28/build/dlfcn:/root/temp/glibc-2.28/build/nss:/root/temp/glibc-2.28/build/nis:/root/temp/glibc-2.28/build/rt:/root/temp/glibc-2.28/build/resolv:/root/temp/glibc-2.28/build/mathvec:/root/temp/glibc-2.28/build/support:/root/temp/glibc-2.28/build/crypt:/root/temp/glibc-2.28/build/nptl /root/temp/glibc-2.28/build/libc.so.6 /root/temp/glibc-2.28/build/libc_nonshared.a -Wl,--as-needed /root/temp/glibc-2.28/build/elf/ld.so -Wl,--no-as-needed -lgcc `gcc -B/usr/bin/ --print-file-name=crtend.o` /root/temp/glibc-2.28/build/csu/crtn.o make[2]: Leaving directory '/root/temp/glibc-2.28/elf' make[1]: Leaving directory '/root/temp/glibc-2.28'
Shell
执行 make install
rm -f /root/temp/glibc-2.28/build/stubs.h /root/temp/glibc-2.28/build/elf/sln /root/temp/glibc-2.28/build/elf/symlink.list rm -f /root/temp/glibc-2.28/build/elf/symlink.list test ! -x /root/temp/glibc-2.28/build/elf/ldconfig || LC_ALL=C \ /root/temp/glibc-2.28/build/elf/ldconfig \ /lib64 /usr/lib64 LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /root/temp/glibc-2.28/build/ /usr/bin/ld: cannot find -lnss_test2 collect2: error: ld returned 1 exit status Execution of gcc -B/usr/bin/ failed! The script has found some problems with your installation! Please read the FAQ and the README file and check the following: - Did you change the gcc specs file (necessary after upgrading from Linux libc5)? - Are there any symbolic links of the form libXXX.so to old libraries? Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong, libm.so should point to the newly installed glibc file - and there should be only one such link (check e.g. /lib and /usr/lib) You should restart this script from your build directory after you've fixed all problems! Btw. the script doesn't work if you're installing GNU libc not as your primary library! make[1]: *** [Makefile:111: install] Error 1 make[1]: Leaving directory '/root/temp/glibc-2.28' make: *** [Makefile:12: install] Error 2
Shell
虽然这次报了很多错误,但是已经安装好了
ls -l /lib64/libc.so.6 lrwxrwxrwx 1 root root 12 Jul 13 19:45 /lib64/libc.so.6 -> libc-2.28.so
Shell
果然已经成功升级
如果 glibc 挂了会导致系统很多命令不可用
ls ls: error while loading shared libraries: /lib64/libc.so.6: invalid ELF header
Shell
可以使用一个正常的 libc 进行恢复,注意此时 ln 命令已经不可用,但 sln 还可以使用
sln /lib64/libc-2.17.so /lib64/libc.so.6
Shell

「真诚赞赏,手留余香」

Foreversmart

真诚赞赏,手留余香

使用微信扫描二维码完成支付