Which of these commands allows you to use shared libraries that are in /usr/local/lib?

Which of these commands allows you to use shared libraries that are in /usr/local/lib?

Which of these commands allows you to use shared libraries that are in /usr/local/lib?

A.
export LD_PRELOAD=/usr/local/lib

B.
export LD_LIBRARY_PATH=/usr/local/lib

C.
ldconfig /usr/local/lib

D.
ldd /usr/local/lib

Explanation:

From the man pages:
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). ldconfig checks the
header and file names of the libraries it encounters when determining which versions should have
their links updated. ldconfig ignores symbolic links when scanning for libraries.
ldd – print shared library dependencies
LD_PRELOAD – a whitespace-separated list of additional, user-specified, ELF shared libraries to

be loaded before all others. This can be used to selectively override functions in other shared
libraries. For set-user-ID/ set-group-ID ELF binaries, only libraries in the standard search
directories that are also set-user-ID will be loaded.
LD_LIBRARY_PATH – a colon-separated list of directories in which to search for ELF libraries at
executiontime.
Similar to the PATH environment variable



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Micha

Micha

C is correct but B would work too.
Depends on the interpretation of the word “use” in the question.
C will add /usr/local/lib to /etc/ld.so.cache so it’s permanently useable systemwide.
B will allow you to USE those libs while LD_LIBRARY_PATH is set.