How to upgrade glibc on CentOS 7
how to upgrade glibc on centos7
⚠ WARNING: Upgrading GLIBC on CentOS 7 is a high-risk operation!
This process can potentially break your system, especially if done incorrectly.
It is highly recommended to backup your system and test the upgrade on a non-production environment first.
Proceed with caution!
⚠ EOL (End-of-Life) era notice: CentOS 7 reached EOL on 2024-06-30, and CentOS 8
(used below only to extract a newerlibstdc++) reached EOL on 2021-12-31; both
centos:7andcentos:8images are frozen archive artifacts. Thedevtoolset-8
SCL packages come from the EOL CentOS 7 repo ecosystem and may require switching yum
tomirror/vault.centos.org.Version ceiling: this trick caps out at glibc 2.31. Modern software (for
example current Node.js LTS releases) requires glibc 2.34 or newer, so this is not a
general path to running recent tooling on CentOS 7. For any new workload, migrate to a
supported OS instead. The well-scoped steps below still work within their 2.31 scope.
This guide provides step-by-step instructions to upgrade the GNU C Library (glibc) and GCC on CentOS 7, along with handling potential issues.
check the current version
1 | gcc --version |
install gcc 8
1 | sudo yum install -y centos-release-scl |
install glibc 2.31
1 | sudo yum groupinstall -y "Development tools" |
issue: "ld: cannot find -lnss_test2"
Maybe you will encounter the following error:
/usr/bin/ld: cannot find -lnss_test2
You can fix it by the following this:
Note: the linked page (garlicspace.com) returns HTTP 404 as of 2026-08 — the link is dead.
The relevant fix is reproduced inline below.
vim ../scripts/test-installation.pl +128
Before changed:
&& $name ne "nss_test1" && $name ne "libgcc_s") {append this condition
&& $name ne "nss_test2"to skip the test of nss_test2Changed:
&& $name ne "nss_test1" && $name ne "nss_test2" && $name ne "libgcc_s") {
upgrade libstdc++, if necessary
After you have installed glibc 2.31, you also replace the old libstdc++.so.6 with the new one.
Before replacing, it looks like this:
ls -l /usr/lib64/libstdc++.so.6*
1 | lrwxrwxrwx. 1 root root 19 Feb 27 22:24 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.19 |
We will replace it with libstdc++.so.6.0.25.
But how to get it? A simple way is to use docker image to get it, like this:
1 | # show the libc and libstdc++ version |
Replaced, it looks like this:
ls -l /usr/lib64/libstdc++.so.6*
1 | lrwxrwxrwx. 1 root root 19 Feb 27 22:24 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.25 |
Question
gnome-terminal cannot open
try this command: sudo localedef -f UTF-8 -i en_US en_US.UTF-8