
strings /lib/x86_64-linux-gnu/libc.so.6 |grep GLIBC_
首先吐槽一下论坛发帖子的功能,以下原文无法直接发出,带图片的都显示图片格式不正确,无奈之下只能使用这种方式发帖 运行软件的错误信息:
Error: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found
由于专业版1070自带的GLIBC库为2.28,而软件需要的版本是2.29,所以导致某些软件无法正常使用,可以使用以下方法处理:
1:下载所需版本的glic库源码: wget https://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.bz2
2:安装源码编译所需要的环境: sudo apt install build-essential bison
3:编译,安装glibc库:
tar xvf glibc-2.29.tar.bz2
cd glibc-2.29
mkdir build
cd build
../configure --prefix=/opt/glibc-2.29
make -j4
sudo make install
4:使用LD_PRELOAD技术运行软件(使用这种方式可以单独指定软件使用指定的库)
LD_PRELOAD=/opt/glibc-2.29/lib/libc.so.6
软件全路径 运行一切正常
5:如果需要在桌面或系统菜单中使用这种方法运行软件,需要修改desktop文件的内容,找到Exec一行修改为Exec=env LD_PRELOAD=/opt/glibc-2.29/lib/libm.so.6 软件全路径 运行一切正常
编译其他项目时,发现需要更高版本的 glibc,所以尝试编译
glibc-2.40
UOS版本:
$ uname -a
Linux athena-PC 4.19.0-amd64-desktop #7112 SMP Thu Jul 18 18:35:56 CST 2024 x86_64 GNU/Linux
glibc版本:https://ftp.gnu.org/gnu/glibc/glibc-2.40.tar.gz
编译过程:
$ tar xzvf glibc-2.40.tar.gz
$ cd glibc-2.40/
$ mkdir build
$ cd build/
$ ../configure --prefix=/usr/
$ make
错误信息:
gcc -nostdlib -nostartfiles -r -o /home/athena/glibc-2.40/build/elf/librtld.os '-Wl,-(' /home/athena/glibc-2.40/build/elf/dl-allobjs.os /home/athena/glibc-2.40/build/elf/rtld-libc.a -lgcc '-Wl,-)' \
-Wl,-Map,/home/athena/glibc-2.40/build/elf/librtld.os.map
gcc -nostdlib -nostartfiles -shared -o /home/athena/glibc-2.40/build/elf/ld.so.new \
-Wl,-z,relro -Wl,-z,defs \
\
/home/athena/glibc-2.40/build/elf/librtld.os -Wl,--version-script=/home/athena/glibc-2.40/build/ld.map \
-Wl,-soname=ld-linux-x86-64.so.2
/usr/bin/ld: /home/athena/glibc-2.40/build/elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `__ehdr_start' can not be used when making a shared object
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: * [Makefile:1380: /home/athena/glibc-2.40/build/elf/ld.so] Error 1
make[2]: Leaving directory '/home/athena/glibc-2.40/elf'
make[1]: * [Makefile:484: elf/subdir_lib] Error 2
make[1]: Leaving directory '/home/athena/glibc-2.40'
make: * [Makefile:9: all] Error 2
错误信息显示 ld 链接器有问题,__ehdr_start不能用于编译共享项目。
原因分析:
通过查看GUN Binutils的版本发现,UOS系统默认安装的GUN Binutils版本为2.31.1,与glibc-2.40不匹配,是造成glib-2.40编译安装失败的主要原因。
$ ld --version GNU ld (GNU Binutils for Uos) 2.31.1 Copyright (C) 2018 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty.
解决方法:
编译安装合适的GUN Binutils
1.获取GUN Binutils
$ git clone git://sourceware.org/git/binutils-gdb.git
或
$ wget https://ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.gz
2.编译安装GUN Binutils
$ tar xzvf binutils-2.43.1.tar.gz
$ cd binutils-2.43.1/
$ ../configure --prefix=/usr/
$ make
$ make install
注意:如果出现binutils-2.43.1源码中定义的'lseek'与UOS系统/usr/include/unistd.h中定义的'lseek'冲突造成编译错误
libtool: compile: gcc -DHAVE_CONFIG_H -I. -U_ASM -I.. -I. -I./../common -I./../src -I./../../include -Wall -Wno-nonnull-compare -g -O2 -MT iotrace.lo -MD -MP -MF .deps/iotrace.Tpo -c iotrace.c -fPIC -DPIC -o .libs/iotrace.o
In file included from ./../src/collector_module.h:27,
from collector.h:29,
from iotrace.c:38:
iotrace.c:2473:1: error: conflicting types for ‘lseek’
llseek (int fildes, offset_t offset, int whence)
^~
/usr/include/unistd.h:338:16: note: previous definition of ‘lseek’ was here
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
^~~~~
make[5]: * [Makefile:624: iotrace.lo] Error 1
make[5]: Leaving directory '/home/athena/binutils-2.43.1/gprofng/libcollector'
make[4]: * [Makefile:478: all] Error 2
make[4]: Leaving directory '/home/athena/binutils-2.43.1/gprofng/libcollector'
make[3]: * [Makefile:472: all-recursive] Error 1
make[3]: Leaving directory '/home/athena/binutils-2.43.1/gprofng'
make[2]: * [Makefile:404: all] Error 2
make[2]: Leaving directory '/home/athena/binutils-2.43.1/gprofng'
make[1]: * [Makefile:7318: all-gprofng] Error 2
make[1]: Leaving directory '/home/athena/binutils-2.43.1'
make: * [Makefile:1028: all] Error 2
可将/usr/include/unistd.h中335行16列的'lseek'暂时修改为'llseek'以规避编译错误
修改时注意及时备份原文件# cp /usr/include/unistd.h /usr/include/unistd.h.bak
修改完的unistd.h的335行应为
define llseek llseek
3.编译安装完成后确认GNU Binutils版本信息
$ ld --version
GNU ld (GNU Binutils) 2.43.1
Copyright (C) 2024 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
至此,glibc-2.40可正常完成编译,编译后在glibc-2.40/build/elf目录下看到编译好的ldd,查看版本信息如下:
$ ./ldd --version
ldd (GNU libc) 2.40
Copyright (C) 2024 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.
Written by Roland McGrath and Ulrich Drepper.
但继续安装时发现如下错误:
Inconsistency detected by ld.so: dl-call-libc-early-init.c: 37: _dl_call_libc_early_init: Assertion 'sym != NULL' failed!
目前还在继续研究中......
评论 (0)