Location>code7788 >text

Linux Ops] How to painlessly upgrade glibc

Popularity:909 ℃/2024-11-20 14:58:29

Environment] kos5.8sp2, kernel5.10

Recently, I needed to build a software environment at work that relied on a higher version of glibc, so it gave the following error during installation:

xxx: /lib64/.6: version 'GLIBC_2.33' not found (required by xxx)

Went to check the current machine's supported GLIBC version and found that it was indeed too low:

strings /usr/lib64/.6 | grep GLIBC

And, the hard part is that this software that needs to be installed is only provided as a binary installer, with no way to make customized changes based on its source code.

It looks like you'll have to upgrade glibc on your current system.

There are a lot of tutorials on replacing glibc on the web, most of which give themake && make install of the program.However this program is and its risks. Because glibc is one of the core libraries of the system, almost all userspace programs depend on it. If you don't consider the risk of directlymake installIf your system hangs when the new glibc installation succeeds, then the odds are that your system will hang. A representative phenomenon is when you execute something likels The simple shell commands are now reporting errors.

In fact, there is a better way to install glibc painlessly, which is to compile the rpm source package based on glibc into an rpm in your local environment and then install it.

My current system is kos5.8SP2, which has the same root as RHEL. So I looked for a Fedora glibc installer:glibc-2.38-19., start compiling below.

mkdir glibc-2.38 && cd glibc-2.38

# Split
rpm2cpio ... /glibc-2.38-19. | cpio -div

# Manual copy to rpmbuild/SOURCE
cp -r * ~/rpmbuild/SOURCE/

# Go to the source directory
cd ~/rpmbuild/SOURCE/

# Install dependencies
yum builddep

# Start building
rpmbuild -ba --nodebuginfo

After successful compilation, the~/rpmbuild/RPMS/ directory to generate the rpm and install it:

cd ~/rpmbuild/RPMS/ && yum install *

After successful installation, verify that glibc has been updated: