O vinculador dinâmico usual no Linux usa um cache para encontrar suas bibliotecas. O cache é armazenado em /etc/ld.so.cache e é atualizado por ldconfig , que examina os caminhos dados em /etc/ld.so.conf (e, atualmente, normalmente arquivos em /etc/ld.so.conf.d ).
Portanto, não há valor padrão para LD_LIBRARY_PATH , a pesquisa de biblioteca padrão não é necessária. Se LD_LIBRARY_PATH for definido, ele será usado primeiro, mas não desativará as outras pesquisas (que também incluem alguns diretórios padrão).
A ld.so(8) manpage tem os detalhes:
If a shared object dependency does not contain a slash, then it is searched for in the following order:
Using the directories specified in the
DT_RPATHdynamic section attribute of the binary if present andDT_RUNPATHattribute does not exist. Use ofDT_RPATHis deprecated.Using the environment variable
LD_LIBRARY_PATH(unless the executable is being run in secure-execution mode; see below). in which case it is ignored.Using the directories specified in the
DT_RUNPATHdynamic section attribute of the binary if present.From the cache file
/etc/ld.so.cache, which contains a compiled list of candidate shared objects previously found in the augmented library path. If, however, the binary was linked with the-z nodefliblinker option, shared objects in the default paths are skipped. Shared objects installed in hardware capability directories (see below) are preferred to other shared objects.In the default path
/lib, and then/usr/lib. (On some 64-bit architectures, the default paths for 64-bit shared objects are/lib64, and then/usr/lib64.) If the binary was linked with the-z nodefliblinker option, this step is skipped.
Se LD_LIBRARY_PATH estiver vazio, é ignorado . Se estiver definido para esvaziar valores (com LD_LIBRARY_PATH=: , por exemplo), esses valores vazios são interpretado como o diretório atual .