升级glibc、gcc、zlib等

时间:2024-03-25 17:34:14

前言:昨天公司先上线一个项目,需要用到Libreoffice开源办公套件,版本为最新版6.2的。这就难为我老人家,没办法,干吧。

成功的路上总是不那么一番风顺,总会有点小瑕疵,才会让人铭记于心。

先介绍环境:

[root@xh-php-01t ~]# cat /etc/redhat-release
CentOS release 6.10 (Final)
[root@xh-php-01t ~]# uname -r
2.6.-.el6.x86_64
[root@xh-php-01t ~]# gcc --version
gcc (GCC) 4.4. (Red Hat 4.4.-)
Copyright (C) Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

第一个问题:

[root@xh-php-01t ~]# libreoffice6.
/opt/libreoffice6./program/oosplash: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/oosplash)
/opt/libreoffice6./program/oosplash: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libuno_sal.so.3)

解决方法:

查看libc.so.6模块支持的gblic版本,strings 命令简单来说就是打印出该模块的所有能打印的信息

[root@test ~]# strings /lib64/libc.so.6|grep GLIB
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_PRIVATE

可以发现centos6.10的glibc所有支持的版本

查看glibc的版本

[root@test ~]# rpm -aq|grep glibc
glibc-common-2.12-1.212.el6.x86_64
glibc-2.12-1.212.el6.x86_64

升级glibc到2.15以上

升级步骤:下载glibc2.15的rpm包(我们不准自己编译),上传到服务器,yum 安装

[root@test ~]# ll glibc2..zip
-rw-r--r--. root root Apr glibc2..zip
[root@test ~]# yum install unzip
[root@test ~]# unzip glibc2..zip
Archive: glibc2..zip
inflating: glibc2./glibc-2.15-.el6.x86_64.rpm
inflating: glibc2./glibc-common-2.15-.el6.x86_64.rpm
inflating: glibc2./glibc-devel-2.15-.el6.x86_64.rpm
inflating: glibc2./glibc-headers-2.15-.el6.x86_64.rpm
inflating: glibc2./glibc-static-2.15-.el6.x86_64.rpm
inflating: glibc2./glibc-utils-2.15-.el6.x86_64.rpm
[root@test ~]# cd glibc2.
[root@test glibc2.]# yum install ./*.rpm

升级之后:第一个问题解决

[root@test glibc2.]# rpm -aq|grep glibc
glibc-2.15-.el6.x86_64
glibc-headers-2.15-.el6.x86_64
glibc-static-2.15-.el6.x86_64
glibc-common-2.15-.el6.x86_64
glibc-devel-2.15-.el6.x86_64
glibc-utils-2.15-.el6.x86_64
[root@test glibc2.]# strings /lib64/libc.so.|grep GLIB
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_2.
GLIBC_PRIVATE

第二个问题:

[root@test glibc2.]# libreoffice6.
/opt/libreoffice6./program/oosplash: /usr/lib64/libstdc++.so.: version `GLIBCXX_3.4.18' not found (required by /opt/libreoffice6.2/program/libuno_sal.so.3)

解决方法:

查看libstdc++.so.6模块支持的gcc版本,strings 命令简单来说就是打印出该模块的所有能打印的信息

[root@test glibc2.]# strings /usr/lib64/libstdc++.so.|grep GLIBCXX
GLIBCXX_3.
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
现在要做的就是找到libstdc++.so.6这个模块是谁提供的,我摸索出来了,你们就不用找了,安装gcc会自动依赖安装libstdc++,而这个模块就是libstdc++包提供的

说明一点:libstdc++.so.6模块是libstdc++包提供的,但是它依赖gcc包

当然包我已经下好了,后面会附上链接。

[root@test ~]# ll gcc4.8.2.zip
-rw-r--r--. root root Apr gcc4.8.2.zip
[root@test ~]# unzip gcc4.8.2.zip
Archive: gcc4.8.2.zip
creating: gcc4.8.2/
inflating: gcc4.8.2/cpp-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/gcc-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/gcc-c++-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/libgcc-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/libgomp-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/libmpc-0.8.-0.3.svn855.el6.x86_64.rpm
inflating: gcc4.8.2/libstdc++-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/libstdc++-devel-4.8.-.el6.x86_64.rpm
inflating: gcc4.8.2/libtool-2.4.-.el6.x86_64.rpm
[root@test ~]# cd gcc4.8.2    
[root@test gcc4.8.2]# yum install ./*.rpm

[root@test gcc4.8.2]# gcc --version
gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-8)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

第三个问题:

[root@test gcc4.8.2]# libreoffice6.
/opt/libreoffice6./program/oosplash: /lib64/libz.so.: version `ZLIB_1.2.3.' not found (required by /opt/libreoffice6.2/program/oosplash)

解决方法:centos6.10的zlib版本是1.2.3,这个软件需要的版本比他高,所以我们要升级zlib

[root@test ~]# wget http://www.zlib.net/fossils/zlib-1.2.5.tar.gz
[root@test ~]# ll zlib-1.2..tar.gz
-rw-r--r--. root root Apr zlib-1.2..tar.gz
[root@test ~]# tar xf zlib-1.2..tar.gz
[root@test ~]# cd zlib-1.2.
[root@test zlib-1.2.]# ./configure --prefix=/usr/local/zlib1.2.5
[root@test zlib-1.2.]# make && make install
把新编译的模块加载到模块库中
[root@test zlib-1.2.]# echo /usr/local/zlib1.2.5/lib/ >>/etc/ld.so.conf
[root@test zlib-1.2.]# ldconfig -v

第四个问题:

[root@test ~]# libreoffice6. --version
/opt/libreoffice6./program/soffice.bin: error while loading shared libraries: libcairo.so.: cannot open shared object file: No such file or directory

解决方法:报错提示说libcairo.so.2没发现,但是/opt/libreoffice6.2/program/soffice.bin程序需要使用它,那我们来看看这个程序运行所需的依赖库还有那些,我们及时i补充它,这里用到ldd命令

[root@test ~]# ldd /opt/libreoffice6./program/soffice.bin
/opt/libreoffice6./program/soffice.bin: /lib64/libdbus-.so.: no version information available (required by /opt/libreoffice6./program/libmergedlo.so)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libnspr4.so)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libcurl.so.4)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libxslt.so.1)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/liblangtag-lo.so.1)
linux-vdso.so. => (0x00007ffd39dba000)
libmergedlo.so => /opt/libreoffice6./program/libmergedlo.so (0x00007f50f26ca000)
libuno_sal.so. => /opt/libreoffice6./program/libuno_sal.so. (0x00007f50f2465000)
libc.so. => /lib64/libc.so. (0x00007f50f20a4000)
libgpgmepp.so. => /opt/libreoffice6./program/libgpgmepp.so. (0x00007f50f1e48000)
libicuuc.so. => /opt/libreoffice6./program/libicuuc.so. (0x00007f50f1a7a000)
libz.so. => /usr/local/zlib1.2.5/lib/libz.so. (0x00007f50f185e000)
libplc4.so => /opt/libreoffice6./program/libplc4.so (0x00007f50f1659000)
libnspr4.so => /opt/libreoffice6./program/libnspr4.so (0x00007f50f141b000)
libnss3.so => /opt/libreoffice6./program/libnss3.so (0x00007f50f10f9000)
libsmime3.so => /opt/libreoffice6./program/libsmime3.so (0x00007f50f0ed2000)
libdl.so. => /lib64/libdl.so. (0x00007f50f0ccd000)
libpthread.so. => /lib64/libpthread.so. (0x00007f50f0ab1000)
libdbus-.so. => /lib64/libdbus-.so. (0x00007f50f0870000)
libicui18n.so. => /opt/libreoffice6./program/libicui18n.so. (0x00007f50f03a2000)
libcurl.so. => /opt/libreoffice6./program/libcurl.so. (0x00007f50f013c000)
libX11.so. => /usr/lib64/libX11.so. (0x00007f50efdff000)
libxml2.so. => /opt/libreoffice6./program/libxml2.so. (0x00007f50efa41000)
libxslt.so. => /opt/libreoffice6./program/libxslt.so. (0x00007f50ef801000)
librt.so. => /lib64/librt.so. (0x00007f50ef5f9000)
liborcus-0.14.so. => /opt/libreoffice6./program/liborcus-0.14.so. (0x00007f50ef2b7000)
liborcus-parser-0.14.so. => /opt/libreoffice6./program/liborcus-parser-0.14.so. (0x00007f50ef077000)
libgio-2.0.so. => /lib64/libgio-2.0.so. (0x00007f50eed5d000)
libgobject-2.0.so. => /lib64/libgobject-2.0.so. (0x00007f50eeb10000)
libglib-2.0.so. => /lib64/libglib-2.0.so. (0x00007f50ee7f9000)
liblcms2.so. => /opt/libreoffice6./program/liblcms2.so. (0x00007f50ee5a0000)
libcairo.so. => not found
libcups.so. => not found
libfontconfig.so. => /usr/lib64/libfontconfig.so. (0x00007f50ee369000)
libfreetype.so. => /usr/lib64/libfreetype.so. (0x00007f50ee0cb000)
libm.so. => /lib64/libm.so. (0x00007f50eddd2000)
libXext.so. => /usr/lib64/libXext.so. (0x00007f50edbc0000)
libSM.so. => not found
libICE.so. => not found
libuno_cppu.so. => /opt/libreoffice6./program/libuno_cppu.so. (0x00007f50ed984000)
libuno_cppuhelpergcc3.so. => /opt/libreoffice6./program/libuno_cppuhelpergcc3.so. (0x00007f50ed697000)
libi18nlangtag.so => /opt/libreoffice6./program/libi18nlangtag.so (0x00007f50ed478000)
libjvmaccesslo.so => /opt/libreoffice6./program/libjvmaccesslo.so (0x00007f50ed270000)
libjvmfwklo.so => /opt/libreoffice6./program/libjvmfwklo.so (0x00007f50ed039000)
libuno_salhelpergcc3.so. => /opt/libreoffice6./program/libuno_salhelpergcc3.so. (0x00007f50ece29000)
libxmlreaderlo.so => /opt/libreoffice6./program/libxmlreaderlo.so (0x00007f50ecc1d000)
libepoxy.so => /opt/libreoffice6./program/libepoxy.so (0x00007f50ec8e8000)
libclewlo.so => /opt/libreoffice6./program/libclewlo.so (0x00007f50ec6e2000)
libclucene.so => /opt/libreoffice6./program/libclucene.so (0x00007f50ec2f1000)
libpdfiumlo.so => /opt/libreoffice6./program/libpdfiumlo.so (0x00007f50ebc6d000)
libstdc++.so. => /usr/lib64/libstdc++.so. (0x00007f50eb963000)
libgcc_s.so. => /lib64/libgcc_s.so. (0x00007f50eb74d000)
/lib64/ld-linux-x86-.so. (0x000055a6647be000)
libgpgme.so. => /opt/libreoffice6./program/libgpgme.so. (0x00007f50eb506000)
libassuan.so. => /opt/libreoffice6./program/libassuan.so. (0x00007f50eb2f3000)
libicudata.so. => /opt/libreoffice6./program/libicudata.so. (0x00007f50e9731000)
libnssutil3.so => /opt/libreoffice6./program/libnssutil3.so (0x00007f50e9501000)
libplds4.so => /opt/libreoffice6./program/libplds4.so (0x00007f50e92fc000)
libssl3.so => /opt/libreoffice6./program/libssl3.so (0x00007f50e90aa000)
libxcb.so. => /usr/lib64/libxcb.so. (0x00007f50e8e85000)
libgthread-2.0.so. => /lib64/libgthread-2.0.so. (0x00007f50e8c80000)
libgmodule-2.0.so. => /lib64/libgmodule-2.0.so. (0x00007f50e8a7d000)
libresolv.so. => /lib64/libresolv.so. (0x00007f50e8863000)
libselinux.so. => /lib64/libselinux.so. (0x00007f50e8643000)
libexpat.so. => /lib64/libexpat.so. (0x00007f50e841b000)
libreglo.so => /opt/libreoffice6./program/libreglo.so (0x00007f50e81ff000)
libunoidllo.so => /opt/libreoffice6./program/libunoidllo.so (0x00007f50e7f97000)
liblangtag-lo.so. => /opt/libreoffice6./program/liblangtag-lo.so. (0x00007f50e7d71000)
libgpg-error-lo.so. => /opt/libreoffice6./program/libgpg-error-lo.so. (0x00007f50e7b5c000)
libXau.so. => /usr/lib64/libXau.so. (0x00007f50e7958000)
libstorelo.so => /opt/libreoffice6./program/libstorelo.so (0x00007f50e773d000)

可以看出ldd可以列出动态可执行程序所依赖的模块文件,上面可以发现该程序还有四个依赖没有找到,后面肯定会报错的,一起看。

[root@test ~]# yum install cairo
[root@test ~]# libreoffice6. --version
/opt/libreoffice6./program/soffice.bin: error while loading shared libraries: libcups.so.: cannot open shared object file: No such file or directory
[root@test ~]# yum install cups
[root@test ~]# libreoffice6. --version
/opt/libreoffice6./program/soffice.bin: error while loading shared libraries: libSM.so.: cannot open shared object file: No such file or directory
[root@test ~]# yum install libSM
[root@test ~]# libreoffice6. --version
/opt/libreoffice6./program/soffice.bin: /lib64/libdbus-.so.: no version information available (required by /opt/libreoffice6./program/libmergedlo.so)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libnspr4.so)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libcurl.so.4)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/libxslt.so.1)
/opt/libreoffice6./program/soffice.bin: /lib64/libc.so.: version `GLIBC_2.' not found (required by /opt/libreoffice6.2/program/liblangtag-lo.so.1)

从上面来看,基本是解决了,但是我们升级的glibc版本还是太低了,要升级到2.17才行,方法都是一样,就不再写了。下面附上用到的包的链接:

链接:https://pan.baidu.com/s/16UAPUq21WDxk6Xuc_oy2fQ
提取码:k3rv