This preview shows page 1. Sign up to view the full content.
Unformatted text preview: s approach would require application programmers to explicitly link the appropriate object modules into their executables, a process that would be error prone and time-consuming:
unix> gcc main.c /usr/lib/printf.o /usr/lib/scanf.o ... The notion of a static library was developed to resolve the disadvantages of these various approaches. Related functions can be compiled into separate object modules and then packaged in a single static library ﬁle. Application programs can then use any of the functions deﬁned in the library by specifying a single ﬁle name on the command line. For example, a program that uses functions from the standard C library and the math library could be compiled and linked with a command of the form:
unix> gcc main.c /usr/lib/libm.a /usr/lib/libc.a At link time, the linker will only copy the object modules that are referenced by the program, which reduces the size of the executable on disk and in memory. On the other hand, the application programmer only needs to include the names of a few library ﬁles....
View Full Document