0%

Dynamic? Static?

1. Goal

Understand the difference between dynamic and static libraries in software

  • Static: link at compile time, make the final program larger
  • Dynamic: link at runtime, require the system to have the lib

When to use?

  • Static: lib is small, not change, need to be optimized
  • Dynamic: lib is large, frequently update

2. Compile Process

  • Preprocessing, remove comments, expand macro
  • Compilation, translate into assembly
  • Assembly, translatie into machine code
  • Linking, combine it with other libraries and modules

3. Linking?

  • Static linking is usually used for local
  • Dynamic linking is usually used for external libraries

How it works?

  • When compiled, it split into object file and combined into a single file
  • Header files should be used to make sure the parameter is correct

References?