In Linux, read how to add the path of the library file, read how to add the path of the library file in Linux, the library file is connected (static library and shared library) and
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, the/lib and/usr/lib directories are used as the default library search paths. Therefore, you can directly use these directories without setting the search path. For libraries outside the default library search path, you need to add the location of the database to the library search path. 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 using 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/etc/ld library list file. so. from the cache. /Etc/ld. so. cache is a non-text data file and cannot be edited directly. it is based on/etc/ld. so. the search path set in conf is generated by the/sbin/ldconfig command to centralize the shared library files in these search paths (the ldconfig command must be executed with the root permission ). Therefore, in order to ensure the library location during program execution, in/etc/ld. so. after setting the library search path in conf, you must also run the/sbin/ldconfig command to update/etc/ld. so. cache file. Ldconfig, to put it simply, 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 (such as just installed glib), or modifying ld. so. after adding a new library path to the conf file, run/sbin/ldconfig to cache all the library files to the ld. so. cache, if not done, even if the library file is clearly under/usr/lib, it will not be used. The result is wrong during compilation, and the xxx Library is missing, check and find that the computer is clearly there, and you want to scold the computer.
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 the path set with-L is preferentially searched, 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 the/etc/ld. so. conf file. The second setting method requires the root permission to change the/etc/ld. so. conf file and execute the/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 changes in the GTK + version, this may cause compatibility issues to applications and cause some program running to be abnormal. To avoid the above situations, the first method is used to set the search path of the library during installation of GTK + and its dependent libraries. 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.