DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C compilation system

Link editing


NOTE: Because this section tries to cover the widest possible audience, it may provide more background than many users will need to link their programs with a C language library. If you are interested only in the how-to, and are comfortable with a purely formal presentation that scants motivation and background alike, you may want to skip to the quick-reference guide in the last subsection.

Link editing refers to the process in which a symbol referenced in one module of your program is connected with its definition in another -- more concretely, the process by which the symbol printf() in our sample source file hello.c is connected with its definition in the standard C library. Whichever link editing model you choose, static or dynamic, the link editor will search each module of your program, including any libraries you have used, for definitions of undefined external symbols in the other modules. If it does not find a definition for a symbol, the link editor will report an error by default, and fail to create an executable program. Multiply defined symbols are treated differently, however, under each approach. For details, see ``Multiply defined symbols''. The principal difference between static and dynamic linking lies in what happens after this search is completed:

This section examines the link editing process in detail. It starts with the default arrangement, and with the basics of linking your program with the standard libraries supplied by the C compilation system. It then details the implementation of the dynamic linking mechanism, and looks at some coding guidelines and maintenance tips for development of dynamically linked libraries. It also considers the reasons why you might prefer dynamic to static linking, for example:



Next topic: Linking with archive libraries
Previous topic: Optimizing your program

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003