In Linux, la is a library file compiled using libtool. It is a text file that records information related to dynamic libraries and static libraries with the same name; this file is the only file saved between platforms through libtool. libtool is a general library support script that only deals with libtool files with suffixes of lo and la.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
la: The library file compiled using libtool is actually a text file that records information about dynamic libraries and static libraries with the same name
How libtool works
libtool is a universal library support script that hides the complexity of using dynamic libraries in a unified and portable interface; using libtool’s standard methods, it can be used on different platforms Create and call dynamic libraries. It can be considered that libtool is an abstraction of gcc, which wraps gcc (or other compilers). Users do not need to know the details. They only need to tell libtool which libraries need to be compiled, and libtool will handle the library dependencies and other details. libtool only deals with libtool files with suffixes of lo and la.
Extended knowledge:
What are the differences between so, o, lo, a, and la files under Linux?
o: Compiled target file
a: Static library, in fact, it is a package of several o files
so: Dynamic link library (shared library)
lo: The target file compiled using libtool actually adds some information to the o file
One of the main functions of libtool is to solve the library dependency problem in the process of compiling large software; it takes on the heavy maintenance work of library dependencies, thus freeing up programmers' human resources. . libtool provides a unified interface, hiding details such as differences in library names between different platforms, generating an abstract high-level library libxx.la with the suffix name la (actually a text file), and assigning the library's dependencies to other libraries. All are written in the file of the la. dependency_libs in this file records all the libraries that the library depends on (some of which are added in the form of .la files); libdir points out the installation location of the library; library_names records the name of the shared library; old_library records the name of the static library .
When the compilation process reaches the link stage, if there is the following command:
$libtool --mode=link gcc -o myprog -rpath /usr/lib –L/usr/lib –la
libtool will go to the /usr/lib path to find liba.la, and then read the actual shared library from it The name (recorded in library_names, such as liba.so) and path (recorded in lib_dir, such as libdir='/usr/lib'), return parameters such as /usr/lib/liba.so to the triggered gcc command line.
If liba.so depends on the library /usr/lib/libb.so, there will be dependency_libs='-L/usr/lib -lb' or dependency_libs='/usr/ in liba.la lib/libb.la' line, if it is the former, it will directly pass "-L/usr/lib -lb" as a parameter to the gcc command line; if it is the latter, libtool will pass it from /usr/lib/libb Read the actual library name and path of libb.so in .la, and then combine it into the parameter "/usr/lib/libb.so" and pass it to the gcc command line.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What file is la in linux. For more information, please follow other related articles on the PHP Chinese website!