Tag Archives: LD_LIBRARY_PATH

LIBRARY_ Path and LD_ LIBRARY_ The difference of path environment variable

Open source software supply chain lighting plan, waiting for you>>>

LIBRARY_ The path environment variable is used to specify the path to find the shared library when finding the DLL during program compilation, for example, to specify the directory of the DLL to be used for GCC compilation. The setting method is as follows (libdir1 and libdir2 are two library directories)

export LIBRARY_PATH=LIBDIR1:LIBDIR2:$LIBRARY_PATH

LD_ LIBRARY_ The path environment variable is used to specify paths other than the system default path when searching the DLL during program loading and running_ LIBRARY_ The path specified in path will be searched before the system default path. The setting method is as follows (libdir1 and libdir2 are two library directories)

export LD_LIBRARY_PATH=LIBDIR1:LIBDIR2:$LD_LIBRARY_PATH

For example, when we develop a program, we often need to use one or some dynamic link libraries. In order to ensure the portability of the program, we can first put these compiled dynamic link libraries in the directory specified by ourselves, and then add these directories to LD in the above way_ LIBRARY_ Path environment variable, so that your program can be dynamically linked to load the library file to run

difference and use: during development, set library_ Path so that GCC can find the DLL it needs at compile time. When publishing, set LD_ LIBRARY_ Path, so that the program can automatically find the dynamic link library when it loads and runs