Linking with
The
The following command line links the object filesx.o , y.o, and z.ointo a shared library, named my_lib.sl:
$ ld
Note that thisld command line is much simpler than the ld command line required to link an executable file (for example, see “Linking with f90 vs. ld” (page 50).
Examples
Example 10 Example
SUBROUTINE say_hi()
PRINT *, 'Hi!'
END SUBROUTINE say_hi
Example 11 Example
SUBROUTINE say_bye()
PRINT *, 'Bye!'
END SUBROUTINE say_bye
Example 12 Example
PROGRAM main
CALL say_hi()
CALL say_bye()
END PROGRAM main
The following command line creates the PIC object files (the
$ f90
The next command line links the object files into the shared library:
$ ld
The last command line compiles the source file greet.f90 and links the object code with the shared library to produce the executable program a.out:
$ f90 greet.f90 my_lib.sl
The following is the output from a sample run of the executable program:
$ a.out
Hi!
Bye!
Using the C preprocessor
You can use the f90 command to pass source files to the C preprocessor (cpp) before they are compiled. If the source files contain C preprocessor directives, cpp will act on the directives, modifying the source text accordingly. The f90 driver will then pass the preprocessed source text to the compiler. Adding cpp directives to program source files and having the cpp command preprocess them is a convenient way to maintain multiple versions of a
60 Compiling and linking