问题描述:
在 CentOS 7 上,安装运行 node v18.19.1 时,报错:
nvm install v18.19.1
查看版本,报错:
[root@CentOS-A ~]# node -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)
解决方案:
升级glibc 2.17至2.28
一、glibc 2.17升级至2.28
[root@CentOS-A ~]# strings /lib64/libc.so.6 | grep GLIBC GLIBC_2.2.5 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3 GLIBC_2.3.4 GLIBC_2.4 GLIBC_2.5 GLIBC_2.6 GLIBC_2.7 GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 GLIBC_2.11 GLIBC_2.12 GLIBC_2.13 GLIBC_2.14 GLIBC_2.15 GLIBC_2.16 GLIBC_2.17
下载、编译、安装
# 新建本地的一个临时目录 mkdir ~/tmp # 下载安装包 wget -c http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz # 解压 tar -zxvf 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 make make install
../configure时报错:
checking if gcc -B/usr/bin/ is sufficient to build libc... no checking for nm... nm checking for python3... no checking for python... python configure: error: *** These critical programs are missing or too old: compiler *** Check the INSTALL file for required versions.
通过上面的报错,看到很多显示no和bad信息的都是版本不够
二、gcc版本不够,那就升级它,原来是4.8.5,给它升级到8.2.0
[root@CentOS-A ~]# gcc -v 使用内建 specs。 COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper 目标:x86_64-redhat-linux 配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux 线程模型:posix gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
下载、安装 gcc8.2.0
yum -y install wget bzip2 gcc gcc-c++ glibc-headers bison # 下载安装包 wget -c https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz # 解压 tar -zxvf gcc-8.2.0.tar.gz cd gcc-8.2.0 # 下载gmp mpfr mpc等供编译需求的依赖项 ./contrib/download_prerequisites # 2024-03-17 23:42:56 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840] -> "./gmp-6.1.0.tar.bz2" [1] # 2024-03-17 23:44:05 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2 [1279284] -> "./mpfr-3.1.4.tar.bz2" [1] # 2024-03-17 23:44:15 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925] -> "./mpc-1.0.3.tar.gz" [1] # 2024-03-17 23:44:31 URL: ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291] -> "./isl-0.18.tar.bz2" [1] # gmp-6.1.0.tar.bz2: OK # mpfr-3.1.4.tar.bz2: OK # mpc-1.0.3.tar.gz: OK # isl-0.18.tar.bz2: OK # 不能在source目录下configure,必须在上一层的目录下 mkdir build cd build ../configure --prefix=/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib make #【注意】这一步执行时间,至少花了1.5个小时,慢慢等等吧!!! make install # 写配置文件 echo -e '\nexport PATH=/usr/local/gcc-8.2.0/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh # 导出头文件 ln -sv /usr/local/gcc-8.2.0/include/ /usr/include/gcc # 使配置生效 ldconfig -v # 导出验证 ldconfig -p | grep gcc # 查看版本 gcc -v
[root@CentOS-A build]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/gcc-8.2.0/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib Thread model: posix gcc version 8.2.0 (GCC)
三、GNU Make版本从 3.82 升级到 4.2.1
查看当前版本:
make -v # GNU Make 3.82 # Built for x86_64-redhat-linux-gnu # Copyright (C) 2010 Free Software Foundation, Inc. # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> # This is free software: you are free to change and redistribute it. # There is NO WARRANTY, to the extent permitted by law.
下载、安装 make 4.2.1
# 下载安装包 wget -c https://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz # 解压 tar -zxvf make-4.2.1.tar.gz # 安装 cd make-4.2.1 # 建立编译目录 mkdir build cd build # 执行 ../configure --prefix=/usr # 执行完,这里需要编译,会生成build.sh文件,然后执行这个文件 sh build.sh # 然后安装 make install # 然后就安装完成了,查看版本 make -v # GNU Make 4.2.1 # Built for x86_64-pc-linux-gnu # Copyright (C) 1988-2016 Free Software Foundation, Inc. # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> # This is free software: you are free to change and redistribute it. # There is NO WARRANTY, to the extent permitted by law.
四、好了,继续搞glibc的升级
cd /root/tmp/glibc-2.28/build ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin make make install
# make install 时,输出的结果 ...... LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /root/tmp/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 '/root/tmp/glibc-2.28' make: *** [Makefile:12: install] Error 2
# 【注意】这上面的问题可以忽略
ls -l /lib64/libc.so.6 # 最后,来看看我们的结果吧 strings /lib64/libc.so.6 | grep GLIBC
输出:
GLIBC_2.2.5 GLIBC_2.2.6 GLIBC_2.3 GLIBC_2.3.2 GLIBC_2.3.3 GLIBC_2.3.4 GLIBC_2.4 GLIBC_2.5 GLIBC_2.6 GLIBC_2.7 GLIBC_2.8 GLIBC_2.9 GLIBC_2.10 GLIBC_2.11 GLIBC_2.12 GLIBC_2.13 GLIBC_2.14 GLIBC_2.15 GLIBC_2.16 GLIBC_2.17 GLIBC_2.18 GLIBC_2.22 GLIBC_2.23 GLIBC_2.24 GLIBC_2.25 GLIBC_2.26 GLIBC_2.27 GLIBC_2.28 GLIBC_PRIVATE
五、解决问题:node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
wget -c https://cdn.frostbelt.cn/software/libstdc%2B%2B.so.6.0.26 cp libstdc++.so.6.0.26 /usr/lib64/ cd /usr/lib64/ ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6
参考: