温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS6.5升级自带glibc-2.12到glibc-2.15的示例分析

发布时间:2021-11-15 16:48:37 来源:亿速云 阅读:161 作者:小新 栏目:云计算

这篇文章将为大家详细讲解有关CentOS6.5升级自带glibc-2.12到glibc-2.15的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

在开发时项目所依赖的包需要更高版本的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_PRIVATE

如果程序编译的时候链接的libc库版本不在程序运行环境下的glibc库支持的libc版本之内,也会报错。于是,系统的所有命令 ls,cp,cd 等等都无法使用了。我们可以到这里找你要的版本,http://ftp.gnu.org/gnu/glibc/,然后解压后安装。

一、首先查看下本机的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&gt;.

二、编译安装
[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/build

[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/>Seeconfig.log' for more details
这个报错是提示你没有gcc和cc编译包

要安装gcc cc 编译包,使用yum安装即可。然后再make、 make install

三、检查验证

[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.so

我们可以看到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&gt;.

注:
1、不要在 glibc源码包里直接执行 ./configure 指令,否则你就等着被虐吧,假如安装包位置是: /path/to/glibc-2.15,正确的姿势是再建一级目录,在那个目录下执行 ./configure 指令
2、不要将 glibc 安装到默认的目录【/usr/local】或者 【任何自定义的目录】,请务必安装到【/usr】目录,否则你就等着被虐吧。

关于“CentOS6.5升级自带glibc-2.12到glibc-2.15的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI