External functions
The external functions required in the design of Linux applications are mainly provided by libraries and system calls.
Difference between the two
System calls in the Linux kernel are located in a kernel mindset, while the library is provided by the engineer in the user state
Function Library Classification
function library can be divided into static function library and dynamic function library according to link way
Storage location
The main libraries used by Linux applications are stored in the/lib,/usr/lib directory, where the dynamic function library is named *.so.*, and the static function library is named *.A.
Features of the static link library
The library function code to be used by the program is copied to the program at the time of the link. If there are multiple processes running in memory at the same time, and using the same library, then there will be multiple copies, which is a waste of space.
Using the static function library
When linking under 1.Linux, the default is the dynamic-link library
2. If you need to use a static library, you need to use the compile option-static
Example: gcc–static hello.c–o Hello
Making a library of static functions
1. Compile into intermediate file gcc–c Mylib.c–o mylib.o
2. Packaged into a static function library ar cqs LIBMYLIB.A mylib.o
3. Copy the prepared LIBMYLIB.A into the/usr/lib
Using the static function library
-LNAME:GCC when linking, only the C function library is linked by default, and for other libraries, you need to use the-l option to indicate that a link needs to be displayed.
Example: Gcc–hello.c–lmylib–o Hello
[Country EMBED strategy] [073] [Static function library design]