如何查找链接库的位置,编译和执行时分别?

发布时间 2023-09-22 23:39:50作者: ffl

GCC 动态链接库链接查找

https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html

  1. It looks in the DT_RPATH section of the executable, unless there is a DT_RUNPATH section.
  2. It looks in LD_LIBRARY_PATH. This is skipped if the executable is setuid/setgid for security reasons.
  3. It looks in the DT_RUNPATH section of the executable unless the setuid/setgid bits are set (for security reasons).
  4. It looks in the cache file /etc/ld/so/cache (disabled with the -z nodeflib linker option).
  5. It looks in the default directories /lib then /usr/lib (disabled with the -z nodeflib linker option).