Table 23 Libraries linked by default on Itanium (continued)

Library

Contents

/usr/lib/hpux[3264]/libc.so

Shared library for intrinsic procedures and system

 

routines

 

 

/opt/fortran90/lib/hpux[3264]/li bF2003.a

Archive library for Fortran 2003 standard features

Linking to nondefault libraries

The -loption enables you to specify other libraries for linking, in addition to the default libraries listed in Table 2-14. The syntax for this option is:

-lx

where xis a sequence of characters that completes a library name of the form /lib/libx.a or /usr/lib/libx.a. For example,-lmspecifies the math library, /usr/lib/libm.a. (The

.aextension indicates an archive library. You can also link to shared libraries, which have the

.slextension; see “Linking to shared libraries” (page 53).)

The -loption is order-sensitive: when the linker finds a reference in an object file that it cannot resolve in the default libraries, it searches the libraries (if any) specified after the file on the command line. For example, the following command line tells the linker to look for unresolved references in the math library as well as the default libraries:

$ f90 prog.f90 -lm

You can also link a library to your program by specifying its name after the name of the source file that references it, as follows:

$ f90 prog.f90 /usr/lib/libm.a

This form of the command line is useful for linking libraries that do not conform to the naming convention required by the-loption or that reside in a directory other than /lib or /usr/lib. As with the -loption, the library name must follow the name of the source file that references it. For example, the following command line links prog.f90with the my_routineslibrary , both of which reside in the current working directory:

$ f90 prog.f90 my_routines

If your program calls routines in a library but the linker is unable to resolve the references, compile with the -Wl,-voption. The f90command passes -vto the linker, causing it to process in verbose mode. The verbose information includes:

The names of the libraries that the linker is searching. This information can confirm that the linker is searching the correct libraries.

The names of the object files selected by the linker to resolve the references. The linker may have found the same name in another library and resolved the reference there.

Many library-related problems are owing to a misplaced-lon the command line. The -Loption (discussed in “Library search rules” (page 54)) is also order-sensitive and can cause similar problems.

Linking HP Fortran 90 routines

When calling HP Fortran 90 routines on the HP 9000 Series 800, you must include the appropriate run-time libraries by adding certain arguments to the aCC command when linking your program. These arguments depend on how the Fortran 90 routines were compiled:

32-bit PA-RISC 1.1 code

-L/opt/fortran90/lib/ -lF90 -lisamstub

32-bit PA-RISC 2.0 code

-L/opt/fortran90/lib/pa2.0/ -lF90 -lisamstub

64-bit PA-RISC 2.0 code

52 Compiling and linking