linux - 动态库查找ld的规则是什么?

标签 linux gcc linker ld

Linux 将链接器时搜索路径和运行时搜索路径分开。

对于运行时搜索路径,我在其man page (8 ld.so) 中找到了ld.so 的规则。 :

  1. DT_RPATH
  2. 环境 LD_LIBRARY_PATH
  3. DT_RUNPATH
  4. ld.so.cache
  5. /lib,/usr/lib

但是对于链接器时搜索路径,ld 运气不好 :(

Man page for ld (1 ld)说,除了 -L 选项:

The default set of paths searched (without being specified with -L) depends on which emulation mode ld is using, and in some cases also on how it was configured.

The paths can also be specified in a link script with the "SEARCH_DIR" command. Directories specified this way are searched at the point in which the linker script appears in the command line.

取决于仿真模式的“默认路径集”是否表示“SEARCH_DIR”?

最佳答案

misssprite , 要查找特定 ELF 仿真的链接器搜索路径,只需运行 ld -m<emulation> --verbose | grep SEARCH_DIR

关于linux - 动态库查找ld的规则是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42808821/

相关文章:

linux - 如何创建递归嵌套的 zip 文件

python - 如何判断文件是否正在从 Linux 写入 Windows CIFS 共享

c++ - 为什么省略 push_back 会使循环运行得更慢?

c++ - 什么会导致 "can' t 链接到共享库上的主可执行文件?

haskell - 制作小型 haskell 可执行文件?

c++ - Visual Studio 2017 上的 NuGet 包 "opencvdefault"链接错误

php - flock() 在 Linux 上可靠吗?

c++ - 如何计算内存分配的数量

c - C 中 Linux 上的内存模式扫描

c++ - 即使启用了 C++11,静态成员初始化也不适用于 GCC