The primary job of the compilation process is to remove symbols. (from symbol to binary)
一個object 檔案存放多個symbol，又稱為symbol table
Defined symbol: 有對應到一個記憶體位址的名稱
Undefined symbol: 沒有對應到記憶體位址的名稱
Defined symbol: global variable, static varible 和funciton
Undefined symbol: extern variable和外部funciton
Static Linking v.s. Dynamic Linking
Static Linking (.a file)
all the library modules are copied to the final executable image. When the program is loaded, OS places only a single file to the memory which contain both the source code and the referencing libraries.
Static linking is done by the linkers in the final step of the compilation.
Statically linked files consume more disk and memory as all the modules are already linked.
In Static linking, if external source program is changed then they have to be recompiled and relinked.
Statically linked programs are faster than their dynamic counterpart.
Since the statically linked file contains every package and module, no compatibility issues occur
Statically linked programs always take constant load time
Dynamic Linking (.so file)
Dynamic linking only the names of external or shared libraries is placed into the memory. Dynamic linking lets many programs use single copy of executable module.
Dynamic linking is done at run time by the OS.
Dynamic linking, only one copy of the reference module is stored which is used by many programs thereby saving memory and disk space.
Dynamic linking only a single module needs to be updated and recompiled.
Dynamic linking, since the library files are separately stored there may be compatibility issues ( say one library file is compiled by new version of compiler).
Load time is variable in dynamically linked programs.