Introduction

Apps are rarely implemented as a single module of code because operating systems implement much of the functionality apps need in libraries. To develop apps, programmers link their custom code against these libraries to get basic functionality, such as the ability to write to standard output or draw complex images using a graphics card. However, linking to libraries creates large executable files and wastes memory. One way to reduce the file size and memory footprint of apps is to reduce the amount of code that is loaded at app launch. Dynamic libraries address this need; they can be loaded either at app launch time or at runtime. Dynamic libraries provide a way for apps to load code when it’s actually needed.

To load dynamic libraries at runtime, apps should use a set of efficient and portable functions, called dynamic loader compatibility functions. Using these functions ensures that dynamic libraries are loaded in the most efficient way and facilitates the porting of apps from one platform to another.

This document is intended for developers of dynamic libraries and developers who use dynamic libraries in their apps. You should be familiar with the Mac OS, UNIX, Solaris, or Linux operating systems. You should also be an experienced C, C++, or Objective-C programmer.

This document explains how dynamic libraries are loaded at app launch time and how to use the DLC functions, dlopen, dlsym, dladdr, dlclose, and dlerror, to load dynamic libraries at runtime. This document also provides guidelines for developing dynamic libraries to be used by client apps.

This document doesn’t address the needs of Carbon or Cocoa programmers who need to load code packaged in a framework or a bundle at runtime or those who want to learn how to package dynamic libraries into frameworks or bundles. The documents Framework Programming Guide, and Code Loading Programming Topics provide information tailored specifically to Carbon and Cocoa developers.

After reading this document, you will understand how dynamic libraries should be implemented so they can be used effectively by client apps. You will also know how to use the cross-platform DLC functions to load dynamic libraries at runtime.

Organization of This Document

This document is comprised by the following articles:

See Also

To complement the information provided in this document, consult the following documents:

You can find further information on dynamic libraries in the following documents: