HP Fortran Programmer's Guide (September 2007)

Compiling and linking
Linking HP Fortran programs
Chapter 2 79
The -l option 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.f90 with the library
my_routines, 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,-v option. The f90 command passes -v to 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” on page 81) 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