对于动态执行某个程序时，发现某个共享库找不到，则可以用 “ldd <可执行文件名>”命令查看可执行文件链接了哪些系统动态链接库。
master@jay-ubuntu:~$ ldd /bin/ls
linux-vdso.so.1 => (0x00007fff79783000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f9a66af6000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9a668ee000)
libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007f9a666e5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9a66326000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9a66122000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9a65f04000)
libattr.so.1 => /lib/x86_64-linux-gnu/libattr.so.1 (0x00007f9a65cff000)
ld combines a number of object and archive files, relocates their data and ties up symbol references. Usually the last step in compiling a program is to run ld.
The linker uses the following search paths to locate required shared libraries:
1. Any directories specified by -rpath-link options.
2. Any directories specified by -rpath options. The difference between -rpath and -rpath-link is that directories specified by -rpath options are included in the executable and used at runtime, whereas the -rpath-link option is only effective at link time. Searching -rpath in this way is only supported by native linkers and cross linkers which have been configured with the --with-sysroot option.
3. On an ELF system, for native linkers, if the -rpath and -rpath-link options were not used, search the contents of the environment variable "LD_RUN_PATH".
4. On SunOS, if the -rpath option was not used, search any directories specified using -L options.
5. For a native linker, the search the contents of the environment variable "LD_LIBRARY_PATH".
6. For a native ELF linker, the directories in "DT_RUNPATH" or "DT_RPATH" of a shared library are searched for shared libraries needed by it. The "DT_RPATH" entries are ignored if "DT_RUNPATH" entries exist.
7. The default directories, normally /lib and /usr/lib.
8. For a native linker on an ELF system, if the file /etc/ld.so.conf exists, the list of directories found in that file. If the required shared library is not found, the linker will issue a warning and continue with the link.
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with -L.
Normally the files found this way are library files---archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with lib and .a and searches several directories.
ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/usr/lib and /lib).
master@jay-ubuntu:~$ cat /etc/ld.so.conf
master@jay-ubuntu:~$ cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
# Multiarch support
master@jay-ubuntu:~$ strings /etc/ld.so.cache | grep pthread
reasons, many people often harrow independently unnoticed. wireless data transmitter Intended for wi-fi programs, the leading supplier usually are battery packs in addition to doesn't need for being of the house or maybe small business electric power brand. The item places strength by battery packs, and so given that battery