centos7 node: /lib64/libm.so.6: version `GLIBC_2.27‘ not found问题解决方案

1、问题

centos7服务器使用nvm安装的node之后,只要使用npm或者node,均会出现以下问题。

npm -v
node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' 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 `GLIBCXX_3.4.21' not found (required by node)

2、原因

查看系统内安装的glibc版本
然后再根据分析可得知 新版的node v18开始 都需要GLIBC_2.27支持,可是目前系统内却没有那么高的版本

 strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
...
GLIBC_2.17
....

3、安装所需要的glibc-2.28

更新glibc
根据提示 安装所需要的glibc-2.28

wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar xf glibc-2.28.tar.gz 
cd glibc-2.28/ && mkdir build  && cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

可能出现的错误
上步更新glibc 可能会发生错误。
如果没有错误 下边这一步 不用看。

make问题

configure: error: 
*** These critical programs are missing or too old: make bison compiler
*** Check the INSTALL file for required versions.

解决办法:升级gcc与make

升级GCC(默认为4 升级为8)

yum install -y centos-release-scl
yum install -y devtoolset-8-gcc*
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++

升级 make(默认为3 升级为4)

wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
tar -xzvf make-4.3.tar.gz && cd make-4.3/
./configure  --prefix=/usr/local/make
make && make install
cd /usr/bin/ && mv make make.bak
ln -sv /usr/local/make/bin/make /usr/bin/make

这时 所有的问题 都已经解决完毕 再重新执行上一步 更新glibc即可

cd /root/glibc-2.28/build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
我的依旧报错:bison太老旧
configure: error: 
*** These critical programs are missing or too old: bison
*** Check the INSTALL file for required versions.

看看我的bison版本多少

安装bison

bison -v
-bash: bison: 未找到命令
yum install -y bison

这时 所有的问题 真的真的都已经解决完毕 再重新执行上一步 更新glibc即可

继续安装glibc-2.28

cd /root/glibc-2.28/build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

make 和 make install在linux中就是安装软件的意思 简单这么理解就好。
这个过程较长,大约半小时左右,建议打一局游戏就好了。

make && make install
# 结果
LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /opt/module/mysql-lib/glibc-2.28/build/
/usr/bin/ld: cannot find -lnss_test2
collect2: error: ld returned 1 exit status
Execution of gcc -B/usr/bin/ failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
- Did you change the gcc specs file (necessary after upgrading from
  Linux libc5)?
- Are there any symbolic links of the form libXXX.so to old libraries?
  Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
  libm.so should point to the newly installed glibc file - and there should be
  only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!
make[1]: *** [Makefile:111: install] Error 1
make[1]: Leaving directory '/opt/module/mysql-lib/glibc-2.28'
make: *** [Makefile:12: install] Error 2

# 这上面的问题可以忽略

make install有报错没有关系

ls -l /lib64/libc.so.6
strings /lib64/libc.so.6 | grep GLIBC
#查询是否有了2.28
GLIBC_2.27
GLIBC_2.28

验证下 是不是好了

npm -v
如果还是出现下面的问题,要连接新的动态库

npm -v
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' 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 `GLIBCXX_3.4.21' not found (required by node)

4、 更新lib libstdc++.so.6.0.26

wget https://cdn.frostbelt.cn/software/libstdc%2B%2B.so.6.0.26

替换系统中的/usr/lib64

cp libstdc++.so.6.0.26 /usr/lib64/

cd /usr/lib64/

ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6
验证

node -v
v20.15.0
  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
报错信息 "node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)" 表明在使用NodeJS18时,系统中缺少了GLIBC 2.27版本所需的库文件。 解决这个问题的方法是升级系统的GLIBC和GCC版本。首先,你需要确保你的系统是CentOS 7.9版本。然后,按照以下步骤来进行升级: 1. 检查GCC版本:执行命令 `gcc --version`,确认GCC版本是否为8.x.x。如果不是,则需要升级GCC。可以使用以下命令来安装最新版本的GCC: ``` sudo yum install centos-release-scl sudo yum install devtoolset-8-toolchain scl enable devtoolset-8 bash ``` 2. 检查GLIBC版本:执行命令 `ldd --version`,确认GLIBC版本是否为2.28或更高版本。如果不是,则需要升级GLIBC。可以使用以下命令来安装最新版本的GLIBC: ``` sudo yum install glibc-devel ``` 3. 更新系统:执行以下命令更新系统并安装所有可用的更新: ``` sudo yum update ``` 4. 验证升级结果:执行命令 `node -v` 来验证是否还有报错。如果没有报错,说明升级成功。 通过以上步骤,你应该能够解决 "node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)" 的报错问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [编译器gcc/glibc升级】CentOS7.9使用NodeJS18时报错/lib64/libm.so.6: version `GLIBC_2.27‘ not found](https://blog.csdn.net/lc1025082182/article/details/129554635)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值