introduction
It is an indispensable tool in modern web development and DevOps practice. With the rapid development, the new version brings many performance optimizations and new features. However, when upgrading versions, especially on older Linux systems, you may encounter some dependency library incompatibility issues, especially withGLIBCandGLIBCXXRelated errors.
This article will provide detailed explanations on how to resolve GLIBC dependencies encountered when upgrading on Linux systems, and provides a variety of solutions, including upgrading the system library, using compatible versions, and running through Docker.
Problem background
When trying to upgrade to 22.9.0 or later, you may encounter the following error:
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node) node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node) node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node) node: /lib64/.6: version `GLIBC_2.27' not found (required by node) node: /lib64/.6: version `GLIBC_2.27' not found (required by node) node: /lib64/.6: version `GLIBC_2.28' not found (required by node) node: /lib64/.6: version `GLIBC_2.25' not found (required by node)
These errors indicate that the current system'sGLIBCandGLIBCXXThe version is too low to meet the dependency requirements.
Solution
1. Check the GLIBC and GLIBCXX versions of the current system
First, we need to confirm the GLIBC and GLIBCXX versions of the current system. Run the following command:
# Check GLIBC versionldd --version | grep -i glibc # Check GLIBCXX versionstrings /lib64/libstdc++.so.6 | grep GLIBCXX
If there is no outputGLIBCXX_3.4.20
、GLIBCXX_3.4.21
orGLIBC_2.27
Such versions indicate that the system library version is too low.
2. Upgrade GLIBC and GLIBCXX
Method 1: Upgrade the system to a distribution that supports higher versions of GLIBC
If your system is an older CentOS or RHEL version (such as CentOS 7), it is recommended to upgrade to a newer distribution (such as CentOS 8 or RHEL 8), because these distributions include later versions of GLIBC by default.
Method 2: Manually upgrade GLIBC and GLIBCXX
If you cannot upgrade the system, you can try to upgrade these libraries manually, but you need to pay attention to risks.
Upgrade GLIBCXX
- Install a higher version
libstdc++
:
sudo yum install -y devtoolset-10 scl enable devtoolset-10 bash
- renew
libstdc++.so.6
Soft link:
sudo ln -sf /opt/rh/devtoolset-10/root/usr/lib64/libstdc++.so.6.0.28 /lib64/libstdc++.so.6
Upgrade GLIBC
- Download and compile a later version of GLIBC:
wget /gnu/libc/glibc-2. tar -xzf glibc-2. cd glibc-2.28 mkdir build cd build ../configure --prefix=/usr make -j$(nproc) sudo make install
- Notice:Upgrading GLIBC may cause system instability and it is recommended to operate in a test environment.
3. Use a compatible version
If your system cannot upgrade GLIBC and GLIBCXX, you can choose to install a version compatible with the current system. For example, or generally requires less GLIBC.
- use
nvm
Install compatible version:
nvm install 16
- Verify installation:
node -v npm -v
4. Run with Docker
If you cannot upgrade the system library and do not want to downgrade the version, you can use Docker to run 22.9.0. Docker containers come with the required dependency library and are not restricted by the host system library.
- Install Docker:
sudo yum install -y docker sudo systemctl start docker sudo systemctl enable docker
- Run the 22.9.0 container:
docker run -it --rm node:22.9.0 bash
- Verify version in container:
node -v npm -v
Summarize
When upgrading a version on a Linux system, you may experience GLIBC and GLIBCXX dependency issues. This article provides a variety of solutions, including upgrading the system library, using compatible versions, and running through Docker. Choose the right method according to your actual situation. If the system library upgrade is at a high risk, it is recommended to use Docker or downgraded version.
Through the guidance of this article, you should be able to successfully resolve the GLIBC dependency problem in the version upgrade and run the latest version smoothly.
The above is the detailed content of various solutions for upgrading GLIBC dependency problems on Linux system. For more information about upgrading GLIBC dependency problems in Linux system, please pay attention to my other related articles!