Http://blog.chinaunix.net/uid-25871104-id-3069931.html
1. How to generate a static library
The static library is just a collection of object objects. You can use the AR command to package the. o file into the. A static library. Assume that GCC has generated. o, B. o, C. o. Use the following command to generate libmylib. A # ar RCS libmylib. a. o B. o C. O
2. How to generate dynamic library is directly generated by GCC. Suppose a. C and B. C files. Use the following command to generate libmylib. So # gcc a. c B. C-o libmylib. So -- shared
3. How to Use the parameters related to the library in the library GCC:-L specifies the directory of the database to be searched, for example, specifying the current directory gcc-L. -l the name of the database to be linked plus the name of the database to be linked is libmylib. a, then gcc-l mylib, that is, head-to-end. -- Static: Use a dynamic library when linking -- generate a dynamic library using shared -- Static-libgcc Link Static libgcc library -- shared-libgcc link dynamic libgcc Library
It can be seen that the use of dynamic and static libraries is the same. If the same library has both dynamic and static libraries, the link to the dynamic library is prioritized unless static is used to force the use of static libraries.