由于项目需要,用到了openresty,安装完成在启动的时候出了个错误
/usr/local/openresty/nginx/sbin/nginx: error while loading shared libraries: /lib64/libgcc_s.so.1: file too short
于是查看是否为链接文件ls -l /lib64/libgcc_s*,如下所示
-rwxr-xr-x 1 root root 93320 Oct 19 11:02 /lib64/libgcc_s-4.4.7-20120601.so.1
-rw-r--r--. 1 root root 0 May 18 2018 /lib64/libgcc_s.so.1
感觉不对劲,心想再对比其他机器(CentOS7)看下,ls -l /lib64/libgcc_s*,如下
-rwxr-xr-x. 1 root root 88776 May 16 2018 /lib64/libgcc_s-4.8.5-20150702.so.1
lrwxrwxrwx. 1 root root 28 Oct 24 18:47 /lib64/libgcc_s.so.1 -> libgcc_s-4.8.5-20150702.so.1
突然就明白了,发现libgcc_s.so.1是一个链接文件,源文件是/lib64/libgcc_s-4.8.5-20150702.so.1,于是回到报错的那台机器,给libgcc_s.so.1添加源文件的链接就行了ln -sf /lib64/libgcc_s-4.4.7-20120601.so.1 /lib64/libgcc_s.so.1,之后重新启动openresty,错误就没有了
-rwxr-xr-x 1 root root 93320 Oct 19 11:02 /lib64/libgcc_s-4.4.7-20120601.so.1
lrwxrwxrwx 1 root root 35 Feb 25 20:49 /lib64/libgcc_s.so.1 -> /lib64/libgcc_s-4.4.7-20120601.so.1
总结: 出现“file too short”一般都是软连接问题,重新建立链接即可。我们知道有动态函数库与静态函数库之分,Linux大多版本是将函数库做成动态函数库,常用的动态函数库加载到内存中(高速缓存),无需要重新从硬盘里读出,提高速度。这种情况是程序链接的动态库中存在软连接文件,但没有“l”标识,即“link”的缩写,被识别成了动态文件,而不是软连接文件,可以看到重新链接之后,链接文件前都多出了“l”标识。加之软连接基本不占空间,文件太小,故报“too short”错误。