Use and fabrication of static function libraries
1. First create a. c file, write the function you want to use inside
2. The compilation does not link the birth into. o File gcc-c mylib.c-o mylib.o
3. Use AR CQS instruction to generate library files such as AR cqs LIBMYLIB.A mylib.o Note that the name of the generated. A file is prefixed with LIB, but it is not prefixed with
4. Copy the made LIBMYLIB.A into the/usr/lib
So a library function is made.
How to use the library function you made
Add the. h file in the directory where you want to use the. c File of the library function, which declares the library function to use
Include the header file in the program, using the ""
Gcc-static-lmylib Test.c-o Test-l represents the use of this function library
Making and using of dynamic function library
1. Same static
2.gcc-shared-fpic Mylib.o-o libmylib.so
3. Same static
Using: GCC test.c-lmylib-o test where-L indicates which link library to use