What is a linker, and what are dynamic and static linking?
Link editors are commonly known as linkers. The compiler automatically
invokes the linker as the last step in compiling a program. The linker
inserts code (or maps in shared libraries) to resolve program library
references, and/or combines object modules into an executable image
suitable for loading into memory. On Unix-like systems, the
linker is typically invoked with the ld command.
Dynamic linking is accomplished by placing the name of a sharable library in the executable image. Actual linking with the library routines does not occur until the image is run, when both the executable and the library are placed in memory. An advantage of dynamic linking is that multiple programs can share a single copy of the library.
Static linking is the result of the linker copying all library routines used in the program into the executable image. This may require more disk space and memory than dynamic linking, but can be more portable, since it does not require the presence of the library on the system where it is run.
For more detailed information, see the Linkers (Link Editors) at Indiana University page.
For more information, refer to Frequently Asked Questions maintained by IU's High Performance Applications staff.
This document was developed with support from the National Science Foundation (NSF) under Grant No. 0503697 to the University of Chicago and subcontracted to Indiana University. Additional support was provided by IU through its participation in the TeraGrid, which is supported by the NSF under Grants No. 0833618, SCI451237, SCI535258, and SCI504075. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the NSF.
Also see:
- When compiling a C program in Unix, why do I get "ld: Unresolved:"?
- On Big Red or Quarry, how do I link to a library?
- Where can I get help using IU's supercomputers?
Last modified on May 13, 2009.






