Linux shared library location configuration

  
 

1. export

Set environment variables

Disadvantages: Only valid for the current shell, reconfigure each time you log in again

export LD_LIBRARY_PATH=/usr/Lib/64

2. /etc/ld.so.conf + ldconfig

Tells the system where to find shared libraries for non-standard paths. Once you change the configuration, you can use it later.

echo /usr/lib/64 >> /etc/ld.so.conf

ldconfig

3. -Wl,-rpath

Run to specify the path to find the shared library, write to the program when compiling

-Wl,-rpath = /usr/lib64

Copyright © Windows knowledge All Rights Reserved