当前位置:Linux教程 - Linux文化 - 关于c 库的版本问题

关于c 库的版本问题


>>> 此贴的回复 >> 假如glibc2.3.4库在当前目录下:/home/firfox/ 安装包为:firfox gcc -g firfox -llibc2.3.4 -L. 其中-l 指定其找的动态库,-L指定库的目录.

>>> 此贴的回复 >> 可能性不大,除非从源代码编译firefox。

>>> 此贴的回复 >> 如果自己写个脚本,在启动firefox之前设置一下LD_PRELOAD环境变量呢?

>>> 此贴的回复 >> 这个方法没想到 >I upgraded my system to Fedora Core 4, and when I try to run an >> application I get >> >> Incorrectly built binary which accesses errno or h_errno directly. >> Needs to be fixed. >> mwrpcss: relocation error: >> /home/luke/Desktop/linux/fpga_82/linux/mfw/lib-linux_optimized/libkernel32.so: >> symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link >> time reference >> >> Is there a NO PAIN way to have 2 versions of glibc running?

No. The absolute name of /lib/ld-linux.so.2 appears in each binary executable program, and ld-linux.so.2 must use its corresponding glibc. So when the operating system performs execve() and gives control to the ELF PT_INTERP, then the required glibc version has been determined.

In order to vary the glibc version, then you must introduce some controlled indirection. You can do this at the filesystem level using chroot, at the shell level by wrapping each binary executable old_program in a script: /path/to/glibc/ld-linux.so.2 --library-path /path/to/glibc:$LD_LIBRARY_PATH \ /new/path/to/old_program "$@" or at the PT_INTERP level by using an indirect runtime loader: http://BitWagon.com/rtldi/rtldi.html

What about using LD_PRELOAD naming the other glibc?

[email protected] wrote:

>> What about using LD_PRELOAD naming the other glibc?

It's too late. During execve() the operating system already chose /lib/ld-linux.so.2. If LD_PRELOAD designates a non-matching libc.so.6, then things might not work. ld-linux and libc [and libm, libdl, ...] must be a matched set.

新闻组为comp.os.linux.development.system, 感觉他说的挺有道理的,哪位朋友试验过?