HP Fortran Programmer Guide (766160-001, March 2014)
Table 23 Libraries linked by default on Itanium (continued)
ContentsLibrary
Shared library for intrinsic procedures and system
routines
/usr/lib/hpux[32|64]/libc.so
Archive library for Fortran 2003 standard features/opt/fortran90/lib/hpux[32|64]/li bF2003.a
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,-lm specifies 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-l option or that reside in a directory other than /lib or /usr/lib.
As with the -l option, 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-l on the command line. The -L option
(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