The difference between those things LIBRARY_PATH and LD_LIBRARY_PATH environment variables great circle

LIBRARY_PATH difference and LD_LIBRARY_PATH environment variables

LIBRARY_PATH and LD_LIBRARY_PATH environment variables are two of Linux, the meaning and role of the two are as follows:

LIBRARY_PATH environment variable is used in during the program compilation specify the shared library search path when looking for a dynamic link library, for example, specify a directory gcc compiler dynamic link library need to use. Set as follows (wherein, LIBDIR1 library directory and two LIBDIR2):

export LIBRARY_PATH=LIBDIR1:LIBDIR2:$LIBRARY_PATH

LD_LIBRARY_PATH environment variable is used in during the program load operation to specify a different path other than the default path when looking for a dynamic link library, pay attention, the path specified in LD_LIBRARY_PATH will be searched before the default path. Set as follows (wherein, LIBDIR1 library directory and two LIBDIR2):

export LD_LIBRARY_PATH=LIBDIR1:LIBDIR2:$LD_LIBRARY_PATH

For example, we developed a program that often requires the use of one or some of the dynamic link library, in order to ensure program portability, these can first compiled dynamic link library on their own under the specified directory, and then follow these above directory to LD_LIBRARY_PATH environment variable to load the library files so your program can run a dynamic link.

The difference between using:

 

 

When developing, setting LIBRARY_PATH, so gcc dynamic link library needs to find the time to compile.

When released, set the LD_LIBRARY_PATH, to be able to automatically find the required dynamic link library is loaded at runtime.

Guess you like

Origin www.cnblogs.com/smarkshare/p/10991458.html