Lect22 - CMSC 216 Introduction to Computer Systems Lecture 22 Libraries Optimization Jan Plane Pete Keleher cfw_jplane [email protected]

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CMSC 216 Introduction to Computer Systems Lecture 22 Libraries & Optimization Jan Plane & Pete Keleher {jplane, [email protected] Administrivia • Read Chapter 7.6-7.13 Libraries 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
L IBRARIES Sections 7.6-7.13, Bryant and O'Hallaron 3 Motivation • Suppose we wrote some really useful functions to do something, and want to distribute them to clients or to other programmers. How can we do this? – give out the source code – give out the object code – in the form of a library • What's a library? Basically a collection of object files that provide compiled functions performing some related tasks (often utility functions) • Libraries can be linked into programs – linking can happen prior to execution (at compilation) – linking can be done during program execution 4
Background image of page 2
Comparison Giving out source code is platform-independent, but it needs to be recompiled and relinked by every client or user. It exposes our intellectual property or trade secrets, which we may not want to do – it also makes details of the implementation visible, and clients may come to rely on that Giving out object code doesn't require recompilation of that object code, but it requires relinking of the application which is going to use it Giving out either object code or a library is platform-dependent, but all we have to provide besides the object code or library is the header file (at most), not the source code Giving out some types of libraries doesn't even require relinking of the application using it 5 Object code vs. library In UNIX systems the linker includes an entire object file in an executable, even if not all the functions in it are used. With libraries, the linker can include the code for only the functions from the library that are actually called by a program The linker has to search through an object file to find each function, but a library can be indexed for faster lookup by the linker, so compilation is slightly faster Some types of libraries allow different executables to share the same library code, saving disk and memory space The UNIX utility nm lists the symbols (functions and other names) in a library 6
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Types of libraries • Static libraries (extension .a , for "archive") – are linked into a program as part of the linking phase of compilation – require space in each executable that uses them, which uses disk space, and memory space during execution – updating a library requires recompiling (relinking) all applications using it – are easy to use
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2012 for the course CMSC 216 taught by Professor Plane during the Spring '11 term at Maryland.

Page1 / 11

Lect22 - CMSC 216 Introduction to Computer Systems Lecture 22 Libraries Optimization Jan Plane Pete Keleher cfw_jplane [email protected]

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online