Skip to main content

16.2) Library Creation And Usage


To create a library of functions, do the following:

  1. Create a header file containing prototypes for the functions
  2. Compile the source files containing the functions to object code files
  3. Bundle the object code files together in a single library archive

To use the library, do the following:

  1. Install the header file in a standard location
    (e.g., /usr/local/include on UNIX-like systems)
  2. Install the library file in a standard location - on UNIX-like systems this could be /usr/local/lib or (on 64-bit machines) /usr/local/lib64
  3. When compiling a program that needs functions from the library, use the relevant compiler options to tell it where to find the header file and library

Subsequent pages explore these steps in more detail.