linux dynamic link library search method; find dynamic link library location; the difference LIBRARY_PATH and LD_LIBRARY_PATH; the difference between LD_LIBRARY_PATH and LD_RUN_PATH;

Before configuring the project today, we found some dynamic link library has changed, and now would like to see the application in which the time dynamic link library used to further check point data;

The following are recorded for linux dynamic link library to find methods and processes configuration dynamic link library location:

The difference LIBRARY_PATH and LD_LIBRARY_PATH: ( reference link )

LIBRARY_PATH is used by gcc before compilation to search directories containing static and shared libraries that need to be linked to your program.

LD_LIBRARY_PATH is used by your program to search directories containing shared libraries after it has been successfully compiled and linked.

As pointed below, your libraries can be static or shared. If it is static then the code is copied over into your program and you don't need to search for the library after your program is compiled and linked. If your library is shared then it needs to be dynamically linked to your program and that's when LD_LIBRARY_PATH comes into play. 

The difference between LD_LIBRARY_PATH and LD_RUN_PATH of: ( reference link )

LD_RUN_PATH is used for the link time resolution of libraries whilst LD_LIBRARY_PATH is used for run time resolution of libraries. LD_RUN_PATH Specifies the directories that are to be searched for libraries at both link and run time.

LD_LIBRARY_PATH indicates to the dynamic loader to search the colon delimited paths for libraries required to execute the binary.  LD_RUN_PATH is used by the linker to specify where to look for libraries only at run time.  This differs ever so slightly from LD_LIBRARY_PATH in that this set of paths are not searched during link time.

DLL search path configurations:

1. above may be used  LD_LIBRARY_PATH environmental variable configuration ;

2. You can use the global configuration file /etc/ld.so.conf, configure the search path of the dynamic link library runtime; then use the ldconfig command, will be loaded into the /etc/ld.so.conf ld.so.cache (requires root privileges);

3. Then use: ldconfig -p | grep "your lib" position to find the required dynamic link library;

4. For the existing program, you can use the ldd "your bin" directly see the current execution procedures required link library;

Kept up to date, please indicate the source; more content, please pay attention cnblogs.com/xuyaowen;

/etc/ld.so.conf.d/x86_64-linux-gnu.conf, multi-architecture supports configurations to x86_64 example:

# Multiarch support
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

Keep updating;

Guess you like

Origin www.cnblogs.com/xuyaowen/p/linux-so-library-path.html