Installation guide

searches all of the directories a second time for a static (an archive) library
(an .a file).
When you develop applications, you might work with private shared
libraries that are contained in directories other than the /usr/shlib
directory. In this case, use the L option to specify these directories. Before
you execute the program, set the LD_LIBRARY_PATH environment variable
to point to the directory containing the private shared libraries. When the
program is executed, the run-time loader, /sbin/loader, examines this
environment variable and searches the path, if defined, before searching
the default list of directories.
Set the LD_LIBRARY_PATH variable in the following ways:
Enter the setenv command at the system prompt, followed by a
colon-separated path. The following example sets the path as current
directory, $HOME/testdir directory (if defined), and the default shared
library directory. For example:
% setenv LD_LIBRARY_PATH .:$HOME/testdir:/usr/shlib
Add the variable definition to your login or shell startup files. For
example, you might add the following line to your .login or .cshrc
file, if you work in the C shell:
setenv LD_LIBRARY_PATH .:$HOME/testdir:/usr/shlib
In the following examples, the /usr/person directory contains two
versions of the special math library: libspecial_math.so is a shared
library and libspecial_math.a is an archive library.
When you link with a shared library, symbols must be referenced before
the linker searches the shared library. Otherwise, the linker does not find
the symbol in the shared library and lists the symbol as undefined.
For example, suppose your library object file, libspecial_math.o, defines
two functions, getvalue and setvalue. Suppose that you create a shared
library, libspecial_math.so, and an archive library,
libspecial_math.a, from the object file. You call the getvalue routine
in the program1 module of your application, and you call the setvalue
routine in the program2 module of your application.
Suppose you link your application using the archive library, as follows:
% cc -non_shared program1.o -lspecial_math program2.o
The application module program1 references the getvalue routine, which
the libspecial_math archive library defines. That library also defines
the setvalue routine, and the linker is able to define setvalue when it
encounters that symbol in the program2 module.
Postmigration Programming Features 8–3