离线的Ubuntu18.04升级GLIBC2.27——解决报错:/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28‘ not found

文章讲述了在Ubuntu18.04服务器上升级GLIBC_2.28时遇到的问题,涉及版本检查、缺失库的下载与安装,以及gcc版本兼容性调整的过程。
摘要由CSDN通过智能技术生成

我的情况

  • 机器是断网的(后续称为服务器)
  • 系统为Ubuntu18.04
  • 报错:
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found

解决过程

1. 查看一下自己的版本

ldd --version

ldd (Ubuntu GLIBC 2.27-3ubuntu1.5) 2.27
Copyright (C) 2018 自由软件基金会。
这是一个自由软件;请见源代码的授权条款。本软件不含任何没有担保;甚至不保证适销性
或者适合某些特殊目的。
由 Roland McGrath 和 Ulrich Drepper 编写。
  • 再查看服务器当前版本,命令如下:
    strings /lib/x86_64-linux-gnu/libc.so.6 | grep GLIBC_

返回的结果如下:

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_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_2.24
GLIBC_2.25
GLIBC_2.26
GLIBC_2.27
GLIBC_PRIVATE

说明服务器当前是没有GLIBC_2.28

2. 其次,在镜像网址上下载一些需要的库,上传到服务器上

在本地先下载好 gawk、bison、m4、texinfo、glbic-2.28 ,并上传到服务器上,下面以gawk为例,展示服务器安装过程,其他只要替换名称。(如果出现权限问题,前头加 sudo)

tar -xJf gawk-5.3.0.tar.xz 
cd gawk-5.3.0/
./configure 
make
make install

然后相应的安装 bison、m4 和 texinfo 。

3. 安装glbic-2.28

tar -zxvf 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 -j18
make install
安装glbic-2.28出现问题,具体如下:

在进行编译安装(make -j18)时候,出现了下面的错误:

glibc-2.28/build/intl/plural.c:69:25: error: static declaration of ‘__gettextlex’ follows non-static declaration
 #define yylex           __gettextlex
                         ^
plural.y:57:12: note: in expansion of macro ‘yylex’
 static int yylex (YYSTYPE *lval, struct parse_args *arg);
            ^~~~~
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:203:5: note: previous declaration of ‘__gettextlex’ was here
 int __gettextlex (YYSTYPE *yylvalp, struct parse_args *arg);
     ^~~~~~~~~~~~
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:70:25: error: static declaration of ‘__gettexterror’ follows non-static declaration
 #define yyerror         __gettexterror
                         ^
plural.y:58:13: note: in expansion of macro ‘yyerror’
 static void yyerror (struct parse_args *arg, const char *str);
             ^~~~~~~
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:200:6: note: previous declaration of ‘__gettexterror’ was here
 void __gettexterror (struct parse_args *arg, const char *msg);
      ^~~~~~~~~~~~~~
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:69:25: error: static declaration of ‘__gettextlex’ follows non-static declaration
 #define yylex           __gettextlex
                         ^
plural.y:57:12: note: in expansion of macro ‘yylex’
 static int yylex (YYSTYPE *lval, struct parse_args *arg);
            ^~~~~
../o-iterator.mk:9: recipe for target '/home/XXX/XXX/glibc-2.28/build/intl/plural.os' failed
make[2]: *** [/home/XXX/wuXXXglibc-2.28/build/intl/plural.os] Error 1
make[2]: *** 正在等待未完成的任务....
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:203:5: note: previous declaration of ‘__gettextlex’ was here
 int __gettextlex (YYSTYPE *yylvalp, struct parse_args *arg);
     ^~~~~~~~~~~~
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:70:25: error: static declaration of ‘__gettexterror’ follows non-static declaration
 #define yyerror         __gettexterror
                         ^
plural.y:58:13: note: in expansion of macro ‘yyerror’
 static void yyerror (struct parse_args *arg, const char *str);
             ^~~~~~~
/home/XXX/XXX/glibc-2.28/build/intl/plural.c:200:6: note: previous declaration of ‘__gettexterror’ was here
 void __gettexterror (struct parse_args *arg, const char *msg);
      ^~~~~~~~~~~~~~
../o-iterator.mk:9: recipe for target '/home/tXXX/XXX/glibc-2.28/build/intl/plural.o' failed
make[2]: *** [/home/tXXX/XXX/glibc-2.28/build/intl/plural.o] Error 1
make[2]: 离开目录“/home/XXX/XXX/glibc-2.28/intl”
Makefile:258: recipe for target 'intl/subdir_lib' failed
make[1]: *** [intl/subdir_lib] Error 2
make[1]: 离开目录“/home/XXX/XXX/glibc-2.28”
Makefile:9: recipe for target 'all' failed
make: *** [all] Error 2

据了解后,发现应该时候gcc版本不兼容的问题,因此,我们还需要先安装一个兼容的gcc版本。

先查看你目前的gcc版本
  • 查看命令如下:gcc --version
    结果为:
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 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.
  • 去镜像网址下载gcc,我选择下载gcc-8.1版本。同时也需要下载其依赖的库,对应为:
    gmp-4.3.2、mpfr-2.4.2、mpc-1.0.2、gcc-8.1.0

  • 【注意】:确保安装的库与glibc2.28兼容,我之前安装了mpfr-2.4.2就与glibc2.28不兼容。直接安装最新版

  • 然后上传到服务器上,依次安装:(在root下进行,先 sudo su

  • 安装 gmp

tar -zxvf gmp-6.3.0.tar.gz
cd gmp-6.3.0
./configure
make
make install
  • 安装 mpfr
tar -zxvf mpfr-4.2.1.tar.gz
cd mpfr-4.2.1
./configure
make
make install
  • 安装 mpc
tar -zxvf mpc-1.0.2.tar.gz
cd mpc-1.0.2
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib --with-mpfr-include=/usr/local/include --with-mpfr-lib=/usr/local/lib
make
make install
  • 安装 gcc
tar -zxvf gcc-8.1.0.tar.gz
cd gcc-8.1.0 && mkdir build && cd build
## 这一步可能会出现问题
../configure --prefix=/usr  --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
make	##(该过程会耗费几个小时时间)
make install

如果…/configure出现下面问题时候:

configure: error: 
I suspect your system does not have 32-bit development libraries (libc and headers). 
If you have them, rerun configure with --enable-multilib. 
If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

则将
../configure --prefix=/usr --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
替换为
../configure --prefix=/usr --enable-languages=c,c++ --disable-multilib

【注意】:
要是configure出错了,保险起见,我们需要清理一下:
运行 make distclean 命令来清除先前的构建文件和配置缓存
运行 rm ./config.cache命令来删除当前目录下的 config.cache 文件

  • 安装glbic-2.28
tar -zxvf 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 -j18
make install
  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值