Centos7.9上安装glibc2.28遇到/usr/bin/ld: cannot find -lnss_test2问题

问题起因

在Centos7.5上源码安装glibc2.28,安装失败,导致系统无法ssh访问,同时,所有命令均报错:ls: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory, 就是因为 glibc 安装过程中覆盖或损坏了系统库文件导致。

无奈,只好重装系统,直接安装了Centos7.9, 然后按照https://blog.csdn.net/ht3hyc/article/details/137056771
中的步骤重新源码安装glib2.28.

问题描述

执行glibc-2.28安装到最后的时候,报错。

tar xvf 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 -j4  && make install

这里系统报错如下:

/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 '/home/install/glibc-2.28'
make: *** [Makefile:12: install] Error 2

经过调查,发现这是一个bug,参考:
sourceware.org/bugzilla/attachment.cgi?id=11157

解决办法

修改glibc-2.28/scripts/test-installation.pl, 将第128行:

  • && $name ne “nss_test1” && $name ne “libgcc_s”) {

修改成:

  • && $name ne “nss_test1” && $name ne “nss_test2” && $name ne “nss_nis” && $name ne “nss_nisplus” && $name ne “libgcc_s”) {

然后重新执行:

make -j4  && make install

原文https://blog.csdn.net/ht3hyc/article/details/137056771
还有2个小问题:

  1. isl.0.18.tar.bz2应该为isl-0.18.tar.bz2:
 wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
 
  1. 安装isl的时候:
# 解压
tar -jxvf isl-0.18.tar.bz2
# 安装
cd isl-0.18
./configure --prefix=/usr/local/isl --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc
make && make install

有网友说应该用下面这个,我也就使用了下面这个命令,没有问题:

./configure --prefix=/usr/local/isl --with-gmp-prefix=/usr/local/gmp 不需要mpfr和mpc,gmp的参数是--with-gmp-prefix

这里有个教训,centos7.5不要轻易去升级高版本的glibc,一定要升级,务必提前在虚拟机上将步骤都搞通了,再用到自己的服务器上,否则,只能跟我一样,业务暂停,重装系统了。

记之。

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值