centos7.9 默认glibc版本为2.17,可以用 ldd --version 命令查看:
[root@node2]# ldd --version
ldd (GNU libc) 2.17
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.
由 Roland McGrath 和 Ulrich Drepper 编写。
下载 glibc2.18,上传到Linux服务器任意位置
http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
解压 tar -zxvf glibc-2.18.tar.gz
tar -zxvf glibc-2.18.tar.gz
创建编译目录
cd glibc-2.18 && mkdir -p build
编译安装
# 编译、安装
## 必需进入build目录-否则无法编译
cd build/
# 构建编译选项
## --prefix=/usr: 指定安装软件的目标路径为 "/usr"
### --prefix=/usr 一定不能改,否则安装不成功
## --disable-profile: 禁用生成用于性能分析的 Profile 数据。
## --enable-add-ons: 启用附加功能。
## --with-headers=/usr/include: 指定头文件所在的路径为 "/usr/include"
## --with-binutils=/usr/bin: 指定 binutils 工具的路径为 "/usr/bin"
### binutils 是一组二进制工具,用于处理可执行文件和目标文件,包括汇编器、链接器和调试器等。这个选项告诉编译器在指定路径中查找所需的 binutils 工具。
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
# 编译
make -j all
# 编译安装
make install
# 解决中文乱码问题
make localedata/install-locales
验证结果
[root@node1 ~]# ldd --version
ldd (GNU libc) 2.18
Copyright (C) 2013 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.
由 Roland McGrath 和 Ulrich Drepper 编写。