1. Concept
1.1 Program Library
A ``program library'' is simply a file containing compiled code (and data) that is to be incorporated    later into a program.
Program libraries allow programs to be more modular, faster to recompile, and easier to update.
Program libraries can be divided into three types: static libraries, shared libraries, and dynamically    loaded (DL) libraries.
1.2 Static and DL Libraries
Static libraries.
– Static libraries are simply a collection of ordinary object files
– Static libraries aren't used as often as they once were, because of the advantages of shared libraries.
DL libraries.
– DL libraries are libraries that are loaded at times other than during the startup of a program.
– DL libraries provide a mechanism for shared code and data, allowing a developer of shared    code/data to upgrade functionality without requiring applications to be re-linked or re-compiled.
1.3 Symbols and Linkage
External libraries provide a wealth of functionality – example: C standard library.
Programs access libraries’ functions and variables via identifiers known as symbols.
Header file declarations/prototypes mapped to symbols at compile time.
Symbols are linked to definitions in external libraries during linking.
Functions, global variables must be allocated memory before use.
Can allocate at compile time (static) or at run time (shared).
Consider the simple hello world program written below:
#include <stdio.h>
const char msg[] = "Hello, world." ;

int main()
    return 0;
– What variables and functions are declared globally?
   msg, main(), puts(), others in stdio.h
이전페이지 / 2 / 다음페이지