Static library (. a)
A deal.c usedeal.c
Focus
1. Gcc-c DEAL.C
Generate DEAL.O
2. AR-RSV LIBDEAL.A DEAL.O
Generate LIBDEAL.A
2.5 You can see which OBG files are contained in a static library by Ar-t LIBDEAL.A
3. Gcc-o usedeal usedeal.c-l./-ldeal
Generating an executable program Usedeal
4../usedeal
Dynamic libraries (. So)
Usedeal.c
Deal.h
Dynamic links
1. o File generation
Gcc-c-fpic-o DEAL.O deal.c
-C means only compilation (compile), not connection. The-o option is used to describe the output file name. GCC will generate a target (object) file DEAL.O.
Note the-fpic option. Pic refers to position independent Code. This option is required for shared libraries to enable dynamic connectivity (linking).
2. So file generation
Gcc-shared-o deal.so DEAL.O
The library file starts with Lib. The shared library file is suffixed with. So. -shared indicates that a shared library is generated.
3.gcc-o Test Usedeal.c-ldeal-l.
Generate Test executable program
./test
Dynamic loading
Cond..
It's too urgent to write a lot of places to add (╯-﹏-) ╯ (┷━━━┷
Reference
Http://www.cnblogs.com/vamei/archive/2013/04/04/2998850.html
Http://www.codeceo.com/article/linux-library.html
Linux Static library and dynamic library