as: error while loading shared libraries: /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so: file too sh

时间:2021-08-20 15:30:21

编译c文件发现这错误

as: error while loading shared libraries: /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so: file too short

通过/sbin/ldconfig -v查询发现情况如下

/sbin/ldconfig: File /usr/lib64/libbfd-2.20.51.0.2-5.44.el6.so is empty, not checked.
/sbin/ldconfig: File /usr/lib64/libsss_idmap.so.0.5.0 is empty, not checked.
/sbin/ldconfig: File /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so is empty, not checked.
/sbin/ldconfig: File /usr/lib64/libasm-0.164.so is empty, not checked.
/sbin/ldconfig: File /usr/lib64/libdw-0.164.so is empty, not checked.

查询发现这几个包都是为空的文件

[root@localhost inotify-tools-3.14]# ll /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so
-rwxr-xr-x. 1 root root 0 May 11 03:12 /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so

解决办法

从别的机器上把这个文件拷贝过来

 scp -p22 root@192.168.1.252:/usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so /usr/lib64/

查看

[root@localhost inotify-tools-3.14]# ll /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so             

 -rwxr-xr-x. 1 root root 990040 May 11 03:12 /usr/lib64/libopcodes-2.20.51.0.2-5.44.el6.so


再进行运行查看是否还会报错


[root@localhost ~]# gcc hello.c 
as: error while loading shared libraries: /usr/lib64/libbfd-2.20.51.0.2-5.44.el6.so: file too short

把文件拷过来

[root@localhost ~]# scp -p22 root@192.168.1.252:/usr/lib64/libbfd-2.20.51.0.2-5.44.el6.so /usr/lib64/
root@192.168.1.252's password: 
libbfd-2.20.51.0.2-5.44.el6.so                                   100%  927KB 927.5KB/s   00:00    
[root@localhost ~]# gcc hello.c 
[root@localhost ~]# 


因为这两个文件也导致gcc无法运行

编译时,会报如下错误


checking for gcc... gcc
checking for C compiler default output file name... 
configure: error: in `/home/whl/tools/inotify-tools-3.14':
configure: error: C compiler cannot create executables
See `config.log' for more details.