在开发时项目所依赖的包须要更高版本的glibc库支持, 而Centos6.5 中glibc默认版本为2.12, 这样调试时可能会遇到报错。但若是不当心把动态库中的libc.so.6给删了,瞬间全部的非系统命令都将没法使用,使用就报错。由于libc.so.6 是c运行时库glibc的软连接,而系统几乎全部程序都依赖c运行时库。程序启动和运行时,是根据libc.so.6 软连接找到glibc库。删除libc.so.6将致使系统的几乎全部程序不能工做。
每一个glibc.so文件有它支持的libc版本,能够经过 strings /lib64/libc.so.6 |grep GLIBC 查看,必定要选择这条命令列出的版本。
[root@test1 ~]# 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_PRIVATEhtml
若是程序编译的时候连接的libc库版本不在程序运行环境下的glibc库支持的libc版本以内,也会报错。因而,系统的全部命令 ls,cp,cd 等等都没法使用了。咱们能够到这里找你要的版本,http://ftp.gnu.org/gnu/glibc/,而后解压后安装。 linux
1、首先查看下本机的glibc版本
[root@test1 ~]# /lib64/libc.so.6
GNU C Library stable release version 2.12, by Roland McGrath et al.
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-4).
Compiled on a Linux 2.6.32 system on 2013-11-05.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>;.ide
2、编译安装
[root@test1 ~]# mkdir -pv /path/to/glibc-2.15/build
[root@test1 ~]# cd /path/to/glibc-2.15/
[root@test1 ~]# wget http://ftp.gnu.org/gnu/glibc/glibc-2.15.tar.gz
[root@test1 ~]# tar xzvf glibc-2.15.tar.gz
[root@test1 ~]# cd /path/to/glibc-2.15/buildui
[root@test1 build]# ../glibc-2.15/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
这一步是关键,必定不要在glibc解压的那个目录执行/configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in /path/to/glibc-2.15/build':<br/>configure: error: no acceptable C compiler found in $PATH<br/>See
config.log' for more details
这个报错是提示你没有gcc和cc编译包调试
要安装gcc cc 编译包,使用yum安装便可。而后再make、 make installcode
3、检查验证htm
[root@test1 build]# ll /lib64/libc*
-rwxr-xr-x 1 root root 1926800 Nov 6 2013 /lib64/libc-2.12.so
-rwxr-xr-x 1 root root 9801125 Apr 22 11:19 /lib64/libc-2.15.so
lrwxrwxrwx. 1 root root 18 Oct 10 2018 /lib64/libcap-ng.so.0 -> libcap-ng.so.0.0.0
-rwxr-xr-x. 1 root root 18672 Nov 5 2010 /lib64/libcap-ng.so.0.0.0
lrwxrwxrwx. 1 root root 14 Oct 10 2018 /lib64/libcap.so.2 -> libcap.so.2.16
-rwxr-xr-x 1 root root 19016 Aug 23 2011 /lib64/libcap.so.2.16
-rwxr-xr-x. 1 root root 197064 Nov 6 2013 /lib64/libcidn-2.12.so
-rwxr-xr-x 1 root root 267972 Apr 22 11:19 /lib64/libcidn-2.15.so
lrwxrwxrwx 1 root root 15 Apr 22 11:19 /lib64/libcidn.so.1 -> libcidn-2.15.so
lrwxrwxrwx. 1 root root 17 Oct 10 2018 /lib64/libcom_err.so.2 -> libcom_err.so.2.1
-rwxr-xr-x 1 root root 17256 Aug 13 2013 /lib64/libcom_err.so.2.1
-rwxr-xr-x 1 root root 43392 Nov 6 2013 /lib64/libcrypt-2.12.so
-rwxr-xr-x 1 root root 142947 Apr 22 11:19 /lib64/libcrypt-2.15.so
lrwxrwxrwx. 1 root root 22 Oct 10 2018 /lib64/libcryptsetup.so.1 -> libcryptsetup.so.1.1.0
-rwxr-xr-x 1 root root 97072 Feb 29 2012 /lib64/libcryptsetup.so.1.1.0
lrwxrwxrwx 1 root root 16 Apr 22 11:19 /lib64/libcrypt.so.1 -> libcrypt-2.15.so
lrwxrwxrwx 1 root root 12 Apr 22 11:19 /lib64/libc.so.6 -> libc-2.15.soci
咱们能够看到2.12版本的旧库文件依然存在,并且还多了2.15版本的库文件,并且软连接文件所有指向了2.15版本。开发
再次确认,发现版本已更新为2.15版了,无需重启。
[root@test1 build]# /lib64/libc.so.6
GNU C Library stable release version 2.15, by Roland McGrath et al.
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-23).
Compiled on a Linux 2.6.32 system on 2019-04-22.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>;.get
注:一、不要在 glibc源码包里直接执行 ./configure 指令,不然你就等着被虐吧,假如安装包位置是: /path/to/glibc-2.15,正确的姿式是再建一级目录,在那个目录下执行 ./configure 指令二、不要将 glibc 安装到默认的目录【/usr/local】或者 【任何自定义的目录】,请务必安装到【/usr】目录,不然你就等着被虐吧。