LD_LIBRARY_PATH is a environment variable that lists directory where executable can search for linux shared library. It's also called the shared library search path.
The value of the environment variable LD_LIBRARY_PATH is a colon-separated (:) set of directories where libraries are searched for first before the standard set of directories.
If you are running on a Solaris system, the LD_LIBRARY_PATH environment variable is used to define the native library path.
There were a couple good reasons why it was invented:
Operating System | Library Path Environment Variable |
---|---|
AIX | LIBPATH |
HP-UX | SHLIB_PATH |
Linux | LD_LIBRARY_PATH |
Solaris | LD_LIBRARY_PATH |
Script search_library.sh where the first parameter is the library searched.
#!/bin/bash
IFS=:
for p in ${LD_LIBRARY_PATH}; do
if [ -e ${p}/${1} ]; then
echo ${p}
fi
done
Example:
search_library.sh libodbc.so
/u01/app/oracle/product/fmw/Oracle_BI1/bifoundation/odbc/lib
/u01/app/oracle/product/TimesTen/tt1122/lib
/u01/app/oracle/product/fmw/Oracle_BI1/common/ODBC/Merant/7.1.5/lib
/u01/app/oracle/product/fmw/Oracle_BI1/bifoundation/odbc/lib
/u01/app/oracle/product/TimesTen/tt1122/lib
/u01/app/oracle/product/fmw/Oracle_BI1/common/ODBC/Merant/7.1.5/lib