How ldd executable finds /usr/lib64/libstdc++.so.6?

时间:2022-02-26 15:31:02

When I run

当我跑

ldd ./myprogram

it shows:

表明:

...
libstdc++.so.6 => /usr/lib64/stdc++.so.6
libm.so.6 => /lib64/libm.so.6
...

/usr/lib64 is not in my LD_LIBRARY_PATH, how does it finds /usr/lib64? When I link 'myprgrom', it was linking libraries from ${HOME}/mynewgcc/.../lib64.

/ usr / lib64不在我的LD_LIBRARY_PATH中,它是如何找到/ usr / lib64的?当我链接'myprgrom'时,它链接了来自$ {HOME} / mynewgcc /.../ lib64的库。

1 个解决方案

#1


1  

The ldconfig program builds a cache for ld.so (called by ldd) or ld-linux.so. Shared objects in /etc/ld.so.conf and /etc/ld.so.conf.d get added to this cache. These paths are cached to allow for faster lookup (as opposed to looking at arbitrary places in the filesystem like LD_LIBRARY_PATH). There are certain defaults for ldconfig as well, namely /lib, /lib64, /usr/lib, and /usr/lib64 (the "trusted" directories) which get added to the directories in the config files (unless ldconfig -n is specified).

ldconfig程序为ld.so(由ldd调用)或ld-linux.so构建缓存。 /etc/ld.so.conf和/etc/ld.so.conf.d中的共享对象将添加到此缓存中。这些路径被缓存以允许更快的查找(而不是查看文件系统中的任意位置,如LD_LIBRARY_PATH)。 ldconfig也有一些默认值,即/ lib,/ lib64,/ usr / lib和/ usr / lib64(“可信”目录),它们被添加到配置文件中的目录中(除非指定了ldconfig -n) )。

#1


1  

The ldconfig program builds a cache for ld.so (called by ldd) or ld-linux.so. Shared objects in /etc/ld.so.conf and /etc/ld.so.conf.d get added to this cache. These paths are cached to allow for faster lookup (as opposed to looking at arbitrary places in the filesystem like LD_LIBRARY_PATH). There are certain defaults for ldconfig as well, namely /lib, /lib64, /usr/lib, and /usr/lib64 (the "trusted" directories) which get added to the directories in the config files (unless ldconfig -n is specified).

ldconfig程序为ld.so(由ldd调用)或ld-linux.so构建缓存。 /etc/ld.so.conf和/etc/ld.so.conf.d中的共享对象将添加到此缓存中。这些路径被缓存以允许更快的查找(而不是查看文件系统中的任意位置,如LD_LIBRARY_PATH)。 ldconfig也有一些默认值,即/ lib,/ lib64,/ usr / lib和/ usr / lib64(“可信”目录),它们被添加到配置文件中的目录中(除非指定了ldconfig -n) )。