bash:environment_variables:ld_library_path
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
bash:environment_variables:ld_library_path [2021/02/02 13:17] – peter | bash:environment_variables:ld_library_path [2021/02/02 13:40] (current) – [BASH - Environment Variables - LD_LIBRARY_PATH] peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== BASH - Environment Variables - LD_LIBRARY_PATH ====== | ====== BASH - Environment Variables - LD_LIBRARY_PATH ====== | ||
+ | |||
+ | **LD_LIBRARY_PATH** tells the dynamic link loader (ld.so, the program that starts all your applications) where to search for the dynamic shared libraries an application was linked against. | ||
+ | |||
+ | Multiple directories can be listed, separated by a colon (:), and this list is then searched before the compiled-in search path(s), and the standard locations (typically /lib, /usr/lib, …). | ||
+ | |||
+ | LD_LIBRARY_PATH can be used for: | ||
+ | |||
+ | * testing new versions of a shared library against an already compiled application | ||
+ | * re-locating shared libraries, e.g. to preserve old versions | ||
+ | * creating a self-contained, | ||
+ | |||
+ | <WRAP alert> | ||
+ | **ALERT: | ||
+ | |||
+ | * **Security**: | ||
+ | * A nasty person could get your application to load a version of a shared library that contains malicious code! | ||
+ | * That’s one reason why setuid/ | ||
+ | * **Performance**: | ||
+ | * This means a lot of system calls to **open()**, that will fail with **ENOENT (No such file or directory)**! | ||
+ | * If the path contains many directories, | ||
+ | * If some (or all) of the directories are in an NFS environment, | ||
+ | * **Inconsistency**: | ||
+ | * LD_LIBRARY_PATH forces an application to load a shared library it was not linked against, and that is quite likely not compatible with the original version. | ||
+ | * This can either be very obvious, i.e. the application crashes, or it can lead to wrong results, if the picked up library not quite does what the original version would have done. | ||
+ | * Especially the latter is sometimes hard to debug. | ||
+ | * **Non-Fixing of actual issue**. | ||
+ | * These settings get dependent on this crutch – and if it is eventually taken away, they start to stumble (i.e. fail to run). | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Example Usage ===== | ||
+ | |||
When an executable is run that relies on shared libraries not defined in the global search path, an error similar to the following is displayed: | When an executable is run that relies on shared libraries not defined in the global search path, an error similar to the following is displayed: | ||
Line 13: | Line 47: | ||
</ | </ | ||
- | ---- | + | ----- |
Typically this problem is fixed by running ldd(1) on the executable, locating the missing shared libraries, and adding one or more directories to the LD_LIBRARY_PATH environment variable: | Typically this problem is fixed by running ldd(1) on the executable, locating the missing shared libraries, and adding one or more directories to the LD_LIBRARY_PATH environment variable: | ||
Line 94: | Line 128: | ||
curl: try 'curl --help' | curl: try 'curl --help' | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ |
bash/environment_variables/ld_library_path.1612271821.txt.gz · Last modified: 2021/02/02 13:17 by peter