HP-UX Linker and Libraries User's Guide

Library Naming Conventions
By convention, library names have the form:
libname. suffix
name is a string of one or more characters that identifies the library.
suffix is .a if the library is an archive library, .sl if the library is a PA-RISC shared library,
or .so if the library is a shared library. (The suffix can be .sl for an IPF shared library.
This naming convention is not recommended, but it is supported for backwards
compatibility with PA-32 and PA-64.)
Typically, library names are referred to without the suffix. For instance, the standard C library is
referred to as libc.
Default Libraries
A compiler driver automatically specifies certain default libraries when it invokes ld. For example,
cc automatically links in the standard library libc, as shown by the -lc option to ld in this example:
$ cc -Aa -v main.c func.c
...
/usr/ccs/bin/ld -o a.out -u__exit -umain main.o func.o -lc
cc: informational note 413: Entering Link editor.
Similarly, the Series 700/800 Fortran90 compiler automatically links with the libcl (C interface),
libisamstub (ISAM file I/O), and libc libraries:
$ f90 -v sumnum.f
...
/usr/ccs/bin/ld -x /opt/langtools/lib/crt0.o \
sumnum.o -lcl -lisamstub -lc
The Default Library Search Path
Following are the default search paths for the libraries:
On Itanium systems, ld searches for libraries in the directory /usr/lib/hpux32 for 32-bit
executables and /usr/lib/hpux64 for 64-bit executables.
On PA-RISC systems, ld searches for libraries in the directory /usr/lib/ for 32-bit
executables and /usr/lib/pa20_64/ for 64-bit executables.
If the -p or -G compiler profiling option is specified on the command line, the compiler directs the
linker to also search:
/usr/lib/libp (for PA32)
/usr/lib/pa20__64/libp (for PA64)
/usr/lib/hpux32/libp (for IPF 32-bit)
/usr/lib/hpux64/libp (for IPF 64-bit)
The default order can be overridden with the LPATH environment variable, the -L linker option,
specifies $ORIGIN in the library path, or the +origin option. These are described in Changing
the“Changing the Default Library Search Path with -L, LPATH, and $ORIGIN” (page 30) .
Link Order
The linker searches libraries in the order in which they are specified on the command line - the
link order. Link order is important in that a library containing an external reference to another
library must precede the library containing the definition. This is why libc is typically the last
24 Compiling and Linking Programs on HP-UX