C static library

Symbols and symbol table

C programmers use static attributes hidden inside a block of variable and function declarations, just like you in java and C ++
using public and private statements in the same.

Each m relocatable object modules have a symbol table, which contains information and m are as defined reference symbols.
In the context of the connector, there are three different symbols:
1) m is defined by the module and other modules can be global symbolic references.
2) is defined by reference to another module and module m global symbols.
3) the symbol m is only partially defined modules and applications. static 

How to connect resolves multiple definitions of the global symbol

Functions and global variables are initialized strong symbol for the global variable is initialized when the symbols
Rule 1: Do not allow more than a strong symbol of the same name.
Rule 2: If there is a plurality of strength weak symbol with the same name and symbol, then the symbol selection strong
Rule 3: If a plurality of weak symbols have the same name, then the symbols from these weak

Connected to a static library

In fact, all of the build system provides a mechanism for all relevant target module package called a separate file,
called a static library (static library), it can be used as the input connector.
When the executable file of an output connector structure, only static copy destination library module referenced application.

This method is a bit implementation and realization of standard functions would be separate from the compiler, programmer and still
maintain an appropriate and convenient.

In the Linux system, static library stored on disk in a special file format called Archive (archive) a.

Guess you like

Origin blog.csdn.net/baiyibin0530/article/details/92796469