Library files are used when they are connected (static databases and shared libraries) and run (only programs that use shared libraries). Their search paths are set in the system. In Linux
And/usr/lib
The two directories are used as the default library search path. Therefore, you can directly use these directories without setting the search path. For libraries outside the default library search path, you must add the location of the database
In the search path of the database. You can use either of the following methods to set the search path for a library file:
Specify the library search path in the environment variable LD_LIBRARY_PATH.
Add the library search path to the/etc/lD. So. conf file.
It is wise to add the paths that may store library files to/etc/lD. So. conf.
The addition method is extremely simple. It is okay to directly write the absolute path of the library file into it, one line at a time. For example:
/Usr/x11r6/lib
/Usr/local/lib
/Opt/lib
Note that the second search path setting method is sufficient for locating the Library (including the shared library and static library) when the program is connected, however, the execution of programs that use the shared library is not
Enough. This is because in order to speed up the positioning of the shared library during program execution and avoid the inefficiency of searching for the shared library using the search path, it is to directly read the library list file
/Etc/lD. So. cache. /Etc/lD. So. cache is a non-text data file and cannot be edited directly. It is based on
The search path set in/etc/lD. So. conf is/sbin/ldconfig
Commands are generated by aggregating the shared library files in these search paths (ldconfig commands must be executed as root ). Therefore, in order to ensure the library location during program execution
After setting the library search path in/etc/lD. So. conf, you must run the/sbin/ldconfig command to update the library search path.
/Etc/lD. So. cache file. Ldconfig
To put it simply, it caches the library files in the paths listed in/etc/lD. So. conf to/etc/lD. So. cache.
For use. Therefore, after installing some library files (for example, just installed Glib), or modifying lD. So. conf to add a new library path, run
/Sbin/ldconfig caches all library files to lD. So. cache. If it is not done, it will not be used even if the library files are clearly under/usr/lib.
In the compilation process, the result is wrong. If the xxx library is missing, you can check it and find that it is clearly there.
When a program is connected, you can specify the search path of the library file (static library and shared library) In addition to the preceding settings. You can also use the-l parameter to explicitly specify the search path. Because-L is used
The configured path will be searched first, so the path of the database to be connected is usually specified in this way.
As mentioned above, there are two ways to set the library search path: In the environment variable LD_LIBRARY_PATH and in/etc/lD. So. conf
File. The second setting method requires the root permission to change the/etc/lD. So. conf file and execute/sbin/ldconfig.
Command. In addition, after the system is restarted, all gtk2-based programs will use the newly installed GTK library at runtime. Unfortunately, due to GTK
Version changes, which may cause compatibility issues to applications and cause program running to be abnormal. To avoid the above situations
The first method is used to set the search path of the library during the installation of the dependent library. This setting method does not require the root permission and is easy to set:
$ Export LD_LIBRARY_PATH =/opt/GTK/lib: $ LD_LIBRARY_PATH
Run the following command to view the setting content of ld_libray_path:
$ Echo $ LD_LIBRARY_PATH
Now, the two settings of the database are complete.