且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

/lib/i386-linux-gnu/libc.so.6、/lib/x86_64-linux-gnu/libc.so.6 和/usr/lib/x86_64-linux-gnu/libc.so 之间有什么区别?

更新时间:2023-02-02 21:35:57

/lib/i386-linux-gnu/libc.so.6

/lib/i386-linux-gnu/libc.so.6

这是该库的 32 位版本.

This is is 32-bit version of the library.

/lib/x86_64-linux-gnu/libc.so.6

/lib/x86_64-linux-gnu/libc.so.6

这是该库的 64 位版本.

This is the 64-bit version of the library.

两者通常都是指向实际库文件的符号链接,通常会根据glibc版本号命名,例如libc-2.15.so

Both are usually symbolic links to the actual library file, which will usually be named according to the glibc release number, for example libc-2.15.so

/usr/lib/x86_64-linux-gnu/libc.so

/usr/lib/x86_64-linux-gnu/libc.so

这不是一个库,而是一个链接描述文件,引用了上面的符号链接.

This is not a library, but a linker script file, which refers to the above symlinks.

为什么我们需要所有这些:

Why do we need all these:

首先,无论安装的 libc 版本如何,链接器都将始终搜索 libc.so,因为编译器驱动程序将始终将 -lc 选项传递给链接器.名称 libc 保持不变并表示库的最新版本.

First, regardless of libc version installed, the linker will always search for libc.so, because the compiler driver will always pass to the linker the -lc options. The name libc stays the same and denotes to most recent version of the library.

符号链接 libc.so.6 以库的 soname 命名,它或多或少对应于库的 ABI 版本.链接到 libc.so 的可执行文件实际上包含对 libc.so.6 的运行时依赖.

The symlinks libc.so.6 are named after the soname of the library, which, more or less corresponds to the ABI version of the library. The executables, linked against libc.so in fact contain runtime dependencies on libc.so.6.

如果我们想象有一天会发布一个与 ABI 严重不兼容的 libc,那么它的 soname 可以命名为 libc.so.7,例如,这个版本可以与旧的 libc.so 共存.6 版本,因此针对一个或另一个链接的可执行文件可以在同一系统***存,

If we imagine the someday a grossly ABI incompatible libc is released, it's soname could be named libc.so.7, for example and this version coukld coexists with the older libc.so.6 version, thus executables linked against one or the other can coexist in the same system,

最后,名称 libc-2.15.so 指的是 libc 版本,当您安装新的 libc 包时,名称将更改为 libc-2.16.so.如果它与以前的版本二进制兼容,libc.so.6 链接将保持这种命名方式,现有的可执行文件将继续工作.

And finally, the name libc-2.15.so refers to the libc release, when you install a new libc package, the name will change to libc-2.16.so. Provided that it is binary compatible with the previous release, the libc.so.6 link will stay named that way and the existing executables will continue to work.