编译安装glibc后报错的解决方法

 admin   2022-08-10 10:04   1108 人阅读  0 条评论

以下仅为我个人推测解决,仅供参考,建议重装

编译安装GLIBC后有几率报错,所以假如make的时候有报错就不要继续install了,而是排查

图片.png

首先进入/usr/lib64目录,libc-2.17.so为你之前的glibc版本,ls命令不可用可以通过tab补全

[root@VM-0-3-centos lib64]# sln /usr/lib64/libc-2.17.so /lib64/libc.so.6 

[root@VM-0-3-centos /]# sln /usr/lib64/ld-2.17.so /usr/lib64/ld-linux-x86-64.so.2

然后就好了
图片.png




上图可以看到安装报错,然后除了cd等少数命令,常用的ls、ln、reboot都用不了了

从输入命令报出的错误可以看到是/lib64/libpthread.so.0 和/lib64/libc-2.18.so重定义错误,libc.so.6未定义glibc版本,ld-linux-x86-64.so.2也一样

因为glibc已经编译过了,所以在编译目录下有新的libc.so.6文件,只能先用sln命令先创建链接了,注意sln要用绝对路径

依次执行

/opt/glibc-2.36/build/libc.so.6是你编译glibc的地方

[root@VM-0-3-centos build]# sln /opt/glibc-2.36/build/libc.so.6 /lib64/libc.so.6
[root@VM-0-3-centos build]# sln /opt/glibc-2.36/build/libc.so.6 /lib64/libdl.so.2
[root@VM-0-3-centos build]# sln /opt/glibc-2.36/build/libc.so.6 /lib64/libpthread.so.0
[root@VM-0-3-centos build]# sln /lib64/ld-linux-x86-64.so.2 /lib64/libc.so.6


当然如果升级失败,还可以使用下面命令还原至系统升级前的版本libc-2.12.so:

LD_PRELOAD=/lib64/libc-2.12.so ln -s /lib64/libc-2.12.so /lib64/libc.so.61

“LD_PRELOAD”是一个环境变量,定义在程序运行前优先加载的动态链接库,本处作用就是在执行后面的ln命令时,指定使用的glibc库,这样命令就可以正常使用了。




最后贴上排错步骤

/bin/install -c -m 644 /opt/glibc-2.36/build/libc.a /usr/lib64/libc.a
/bin/install -c -m 644 /opt/glibc-2.36/build/libc_nonshared.a /usr/lib64/libc_nonshared.a
/bin/install -c /opt/glibc-2.36/build/libc.so /lib64/libc.so.6.new
mv -f /lib64/libc.so.6.new /lib64/libc.so.6
gcc -B/usr/bin/   -shared -nostdlib -nostartfiles \
      -x assembler /dev/null -o /opt/glibc-2.36/build/format.lds.so
gcc: relocation error: /lib64/libc.so.6: symbol __tunable_get_val, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
make[1]: *** [Makerules:1033: /opt/glibc-2.36/build/format.lds] Error 127
make[1]: Leaving directory '/opt/glibc-2.36'
make: *** [Makefile:12: install] Error 2
[root@VM-0-3-centos build]# make localedata/install-locales
make: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# strings /lib64/libc.so.6 | grep GLIBCll /lib64/libc.so*
grep: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
strings: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# reboot
reboot: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# cd /lib
lib/   lib64/
[root@VM-0-3-centos build]# cd /l
lib/        lib64/      lost+found/
[root@VM-0-3-centos build]# cd /lib64/
audit/            device-mapper/    fipscheck/        gettext/          libnl/            man-db/           openssl/          plymouth/         rsyslog/          sse2/             tls/              
bind9-export/     dyninst/          games/            gio/              libproxy/         mozilla/          perl5/            pm-utils/         rtkaio/           sssd/             X11/              
cifs-utils/       ebtables/         gconv/            girepository-1.0/ libuser/          NetworkManager/   pkcs11/           python2.7/        sasl2/            systemtap/        xtables/          
dbus-1/           elfutils/         gdk-pixbuf-2.0/   krb5/             lua/              nss/              pkgconfig/        python3.6/        security/         tc/               
[root@VM-0-3-centos build]# cd /lib64/
[root@VM-0-3-centos lib64]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos lib64]# ls /lib64/lib
Display all 663 possibilities? (y or n)
[root@VM-0-3-centos lib64]# ls /lib64/libc.so
libc.so    libc.so.6  
[root@VM-0-3-centos lib64]# ls /lib64/libc.so.6
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos lib64]# poweroff
poweroff: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos lib64]# shutdown -f
shutdown: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos lib64]# cd /opt/glibc-2.36/
[root@VM-0-3-centos glibc-2.36]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# rm -rf build/
rm: relocation error: /lib64/libc.so.6: symbol _dl_audit_preinit, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
[root@VM-0-3-centos glibc-2.36]# make
make: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# cd /lib
lib/   lib64/
[root@VM-0-3-centos glibc-2.36]# cd /lib64/
audit/            device-mapper/    fipscheck/        gettext/          libnl/            man-db/           openssl/          plymouth/         rsyslog/          sse2/             tls/              
bind9-export/     dyninst/          games/            gio/              libproxy/         mozilla/          perl5/            pm-utils/         rtkaio/           sssd/             X11/              
cifs-utils/       ebtables/         gconv/            girepository-1.0/ libuser/          NetworkManager/   pkcs11/           python2.7/        sasl2/            systemtap/        xtables/          
dbus-1/           elfutils/         gdk-pixbuf-2.0/   krb5/             lua/              nss/              pkgconfig/        python3.6/        security/         tc/               
[root@VM-0-3-centos glibc-2.36]# cp
cp: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# /usr/bin/ls
ls        lsattr    lsblk     lscpu     lsinitrd  lsipc     lslocks   lslogins  lsmcli    lsmd      lsmem     lsns      lsscsi    
[root@VM-0-3-centos glibc-2.36]# /usr/bin/ls
/usr/bin/ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# export LD_PRELOAD=/lib64/libpthread.so.0
[root@VM-0-3-centos glibc-2.36]# ls
ls: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# export LD_PRELOAD=/lib64/libdl.so.2
[root@VM-0-3-centos glibc-2.36]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# export LD_PRELOAD=libc.so.6
[root@VM-0-3-centos glibc-2.36]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# ln -s /lib64/libc-2.18.so /lib64/libc.so.6
ln: relocation error: /lib64/libc.so.6: symbol _dl_audit_preinit, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
[root@VM-0-3-centos glibc-2.36]# ln
ln: relocation error: /lib64/libc.so.6: symbol _dl_audit_preinit, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
[root@VM-0-3-centos glibc-2.36]# export LD_PRELOAD=ld-linux-x86-64.so.2
[root@VM-0-3-centos glibc-2.36]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos glibc-2.36]# lsn /usr/lib64/ld-2.17.so /usr/lib64/ld-linux-x86-.so.
-bash: lsn: command not found
[root@VM-0-3-centos glibc-2.36]# sln
Usage: sln src dest|file

For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
[root@VM-0-3-centos glibc-2.36]# sln /lib64/libc-2.18.so /lib64/libc.so.6
Invalid link from "/lib64/libc-2.18.so" to "/lib64/libc.so.6": No such file or directory
[root@VM-0-3-centos glibc-2.36]# sln  /lib64/libc.so.6 /lib64/libc-2.18.so
Invalid link from "/lib64/libc.so.6" to "/lib64/libc-2.18.so": No such file or directory
[root@VM-0-3-centos glibc-2.36]# ls
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos glibc-2.36]# yum
/usr/bin/python: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos glibc-2.36]# ls
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos glibc-2.36]# cd build/
[root@VM-0-3-centos build]# ls
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos build]# sln li
libanl.map             libc-abis.stamp        libc-modules.stmp      libcrypt.map           libio/                 libnsl.map             libnss_files.map       librt.map              link-defines.h.d       
libBrokenLocale.map    libc_malloc_debug.map  libc_nonshared.a       libc.so                libm.map               libnss_compat.map      libnss_hesiod.map      libthread_db.map       linkobj/               
libc.a                 libc.map               libc_pic.a             libc.so.6              libmvec.map            libnss_db.map          libpthread.map         libutil.map            
libc-abis.h            libc-modules.h         libc_pic.os            libdl.map              libmvec.mk             libnss_dns.map         libresolv.map          link-defines.h         
[root@VM-0-3-centos build]# sln libc.so
libc.so    libc.so.6  
[root@VM-0-3-centos build]# sln libc.so.6 /lib64/libc.so.6
Invalid link from "libc.so.6" to "/lib64/libc.so.6": Too many levels of symbolic links
[root@VM-0-3-centos build]# ll
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos build]# ls
ls: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos build]# cat
cat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[root@VM-0-3-centos build]# cd /lib64/
audit/            device-mapper/    fipscheck/        gettext/          libnl/            man-db/           openssl/          plymouth/         rsyslog/          sse2/             tls/              
bind9-export/     dyninst/          games/            gio/              libproxy/         mozilla/          perl5/            pm-utils/         rtkaio/           sssd/             X11/              
cifs-utils/       ebtables/         gconv/            girepository-1.0/ libuser/          NetworkManager/   pkcs11/           python2.7/        sasl2/            systemtap/        xtables/          
dbus-1/           elfutils/         gdk-pixbuf-2.0/   krb5/             lua/              nss/              pkgconfig/        python3.6/        security/         tc/               
[root@VM-0-3-centos build]# sln /lib64/libc.so
Display all 156 possibilities? (y or n)
[root@VM-0-3-centos build]# sln -h
-h: file open error: No such file or directory
[root@VM-0-3-centos build]# sln libc
libc.a                 libc-abis.stamp        libc.map               libc-modules.stmp      libc_pic.a             libcrypt.map           libc.so.6              
libc-abis.h            libc_malloc_debug.map  libc-modules.h         libc_nonshared.a       libc_pic.os            libc.so                
[root@VM-0-3-centos build]# sln libc.so.6 /lib64/libc
libc-2.17.so             libcap.so.2              libcidn.so.1             libconfig.so.9           libcrack.so.2            libcrypt-2.17.so         libcryptsetup.so.12.3.0  libcrypt.so.1            libcurl.so.4.3.0
libc.a                   libcap.so.2.22           libc_nonshared.a         libconfig++.so.9         libcrack.so.2.9.0        libcrypto.so.10          libcryptsetup.so.4       libc.so                  
libcap-ng.so.0           libcidn-2.17.so          libcom_err.so.2          libconfig.so.9.1.3       libcroco-0.6.so.3        libcrypto.so.1.0.2k      libcryptsetup.so.4.7.0   libcurl.so               
libcap-ng.so.0.0.0       libcidn.so               libcom_err.so.2.1        libconfig++.so.9.1.3     libcroco-0.6.so.3.0.1    libcryptsetup.so.12      libcrypt.so              libcurl.so.4             
[root@VM-0-3-centos build]# sln libc.so.6 /lib64/libc.so.6
Invalid link from "libc.so.6" to "/lib64/libc.so.6": Too many levels of symbolic links
[root@VM-0-3-centos build]# sln /opt/glibc-2.36/build/libc.so.6 /lib64/libc.so.6
[root@VM-0-3-centos build]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# cd /lib
lib/   lib64/
[root@VM-0-3-centos build]# cd /lib64/lib
libnl/    libproxy/ libuser/  
[root@VM-0-3-centos build]# sln /lib64/lib
Display all 663 possibilities? (y or n)
[root@VM-0-3-centos build]# sln /lib64/libpth
libpthread-2.17.so      libpthread_nonshared.a  libpthread.so           libpthread.so.0         libpth.so.20            libpth.so.20.0.27       
[root@VM-0-3-centos build]# sln /lib64/libpth
libpthread-2.17.so      libpthread_nonshared.a  libpthread.so           libpthread.so.0         libpth.so.20            libpth.so.20.0.27       
[root@VM-0-3-centos build]# export LD_PRELOAD=/lib64/libc.so.6
[root@VM-0-3-centos build]# ls
ls: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# reboot
reboot: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# sln /opt/glibc-2.36/build/libc.so.6 /lib64/libpthread.so.0
[root@VM-0-3-centos build]# ls
ls: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# ls
ls: relocation error: /lib64/libdl.so.2: symbol _dl_vsym, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
[root@VM-0-3-centos build]# sln /opt/glibc-2.36/build/libc.so.6 /lib64/libdl.so.2
[root@VM-0-3-centos build]# ls
ls: relocation error: /lib64/libc.so.6: symbol __tunable_get_val, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
[root@VM-0-3-centos build]# sln /lib64/ld-linux-x86-64.so.2 /lib64/libc.so.6
[root@VM-0-3-centos build]# ls
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ls)
ls: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by ls)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by ls)
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.8' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libcap.so.2)
ls: /lib64/libc.so.6: version `GLIBC_2.8' not found (required by /lib64/libcap.so.2)
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libacl.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libacl.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libpcre.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libpcre.so.1)
[root@VM-0-3-centos build]# export LD_PRELOAD=/lib64/libc.so.6
[root@VM-0-3-centos build]# ls
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ls)
ls: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by ls)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by ls)
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.8' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libselinux.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libcap.so.2)
ls: /lib64/libc.so.6: version `GLIBC_2.8' not found (required by /lib64/libcap.so.2)
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libacl.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libacl.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libpcre.so.1)
ls: /lib64/libc.so.6: version `GLIBC_2.3.4' not found (required by /lib64/libpcre.so.1)
[root@VM-0-3-centos build]# cd
[root@VM-0-3-centos ~]#

本文地址:https://liuchunjie.top/?id=453
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!

 发表评论


表情

还没有留言,还不快点抢沙发?