Libraries – HP SunSoft Pascal 4.0 User Manual

Page 98

Advertising
background image

74

Pascal 4.0 User’s Guide

4

Libraries

You can use a module unit as a library of useful functions. The simplest way
to do so is to create a source file containing the definitions of your library
routines and then compile it using the

-c

option. You can then link the

resulting

.o

file to any number of files. For convenience, you probably should

create a header file containing the routine declarations for the library.

A simple library as described above has two problems:

When a library grows in size, it may become inconvenient to store its source
in a single file, both for ease of editing and so you can avoid recompiling a
large file when you change only part of it.

On the other hand, it would be inconvenient to have to name many library
modules on the command-line when you link your program. Thus, it would
be helpful to be able to combine a number of library modules.

Several programs that you run at the same time may share the same library.
Under the scheme described above, each program has its own copy of the
library. It saves space and even I/O time if several programs share library
code.

Both problems have solutions. First, you can combine or archive modules
together. Secondly, you can create a shared library.

See the Solaris documentation on the linker and libraries for information on
creating archived and shared libraries.

Advertising