在開發時項目所依賴的包須要更高版本的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】目錄,不然你就等着被虐吧。