There are two types of Unix link libraries: Static libraries and dynamic libraries.
The static library links the Access program in the link time, the runtime does not need the link library existence.
Dynamic libraries are loaded (statically loaded) at program startup, or loaded (dynamically loaded) at run time.
LDD command: View the dynamic libraries associated with the program.
Linux has a dynamic library file with the extension ". So" (Shared Object). By convention, all dynamic library file names are in the form of libname.so (possibly by adding a version number to the name). Thus, the thread function library is called libthread.so. The file name of the static library is libname.a. The file name of the shared archive is libname.sa. Shared archive is just a transitional form that helps people shift from static libraries to dynamic libraries.
Look at the static library first
First, the static library liblt.a.
1. $ gcc-o lt.o-c lt.c
2. $ ar cqs liblt.a lt.o
Furthermore, links,
1. $ gcc TEST.O liblt.a-o test
This time to see his reference library situation.
1. $ LDD Test
2. Linux-gate.so.1 => (0xffffe000)
3. Libc.so.6 =>/lib/libc.so.6 (0xb7e29000)
4./lib/ld-linux.so.2 (0xb7f6e000)
Dynamic Library
Make the dynamic library liblt.so.
1. $ gcc-o lt.o-c lt.c
2. $ gcc-shared-wall-fpic-o liblt.so lt.o-shared
This option specifies that the build dynamic connection library (which allows the connector to generate an export symbol table of type T, and sometimes a weakly connected W-type export symbol) without the flag external program cannot connect. Equivalent to an executable file
-fpic: For code that is compiled as location independent, the compiled code is location-dependent without this option, so dynamic loading is a way to copy the code to meet the needs of different processes, but not the purpose of real code segment sharing.
-L.: Indicates the library to connect to in the current directory
-ltest: When the compiler looks for a dynamic connection library, there is an implied naming rule, that is, precede the given name with Lib, followed by. So to determine the name of the library Ld_library_path: This environment variable indicates that the dynamic connector can load the path of the dynamic library.