HP 3000 Manuals

Using a Relocatable Library [ HP Link Editor/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Link Editor/XL Reference Manual

Using a Relocatable Library 

Relocatable libraries enable you to share procedures (subprograms)
with other subprograms while letting you modify and compile them
independently.

The next three sections explain the primary ways to use relocatable
libraries.  They show how to place the subroutines and functions
contained in a source file into a relocatable library and how to use them
once they are placed there.  To see the relationships of the source files
used in the following figures, see the listings for them in the last
section of this chapter titled, "Sample Programs".

Creating a Relocatable Library 

Figure 2-4 shows how to create a relocatable library and how to add
modules to it at the same time.  This example also shows how to
efficiently organize source files to be added to a relocatable library.

In order to independently compile the subroutines and functions in the HP
FORTRAN 77 source file, EX2BSRC, it is split into five separate source
files:  LIB1SRC, LIB2SRC, LIB3SRC, LIB4SRC, and LIB5SRC. These modules
are compiled producing five separate relocatable object files:  LIB1OBJ,
LIB2OBJ, LIB3OBJ, LIB4OBJ, and LIB5OBJ. (The modules are placed in
different source files because each source file will become one
relocatable object module.)  After entering HP Link Editor\XL by entering
LINKEDIT command at the MPE XL prompt, figure 2-4 shows using the link
editor BUILDRL command to create the relocatable library, LIBRL. Then the
ADDRL command is used to add the relocatable object files to the
relocatable library.  Finally, use the EXIT command to terminate HP Link
Editor\XL.
___________________________________________________________________
|                                                                 |
|     :FTNXL LIB1SRC,LIB1OBJ                                      |
|     :FTNXL LIB2SRC,LIB2OBJ                                      |
|     :FTNXL LIB3SRC,LIB3OBJ                                      |
|     :FTNXL LIB4SRC,LIB4OBJ                                      |
|     :FTNXL LIB5SRC,LIB5OBJ                                      |
|     :LINKEDIT                                                   |
|     LinkEd> BUILDRL RL=LIBRL                                    |
|     LinkEd> ADDRL FROM=LIB1OBJ,LIB2OBJ,LIB3OBJ,LIB4OBJ,LIB5OBJ  |
|     LinkEd> EXIT                                                |
___________________________________________________________________

          Figure 2-4.  Creating a Relocatable Library and Adding Modules to It 

Alternatively, you can have the compiler (rather than the link editor)
create the relocatable library and add modules to it.  This may be the
fastest and easiest choice if you're compiling MPE V source files that
contain several subroutines and functions.  To do this, use the $RLFILE
compiler directive (see the HP FORTRAN 77/XL Reference Manual).

Searching a Relocatable Library 

Figure 2-5 shows how to link the relocatable object file, EX2AOBJ, using
the relocatable library, LIBRL, to resolve external references.  (This
library was created in figure 2-4.)  The :LINK command produces the
executable program file, EX2PROG.
___________________________________________________________________
|                                                                 |
|     :LINK FROM=EX2AOBJ;RL=LIBRL;TO=EX2PROG                      |
___________________________________________________________________

          Figure 2-5.  Searching a Relocatable Library 

Updating a Relocatable Library 

Figure 2-6 shows how to replace a relocatable object module in a
relocatable library.  The relocatable module, LIB4OBJ, is replaced by a
newly-compiled version.  The first command in figure 2-6 compiles the HP
FORTRAN 77 source file, LIB4SRC. Then, after entering the link editor,
the RL command in the third line sets the default relocatable library to
LIBRL. To update the existing relocatable module, the old version is
purged and a new one added.  The PURGERL command purges the existing
relocatable module, LIB4SRC, from the library.  (The name of the module
in the relocatable library is its source file name, LIB4SRC, unless the
$RLFILE compiler option is used.)  The ADDRL command then adds the
updated relocatable object file, LIB4OBJ, to the library.
___________________________________________________________________
|                                                                 |
|     :FTNXL LIB4SRC,LIB4OBJ                                      |
|     :LINKEDIT                                                   |
|     LinkEd> RL RL=LIBRL                                         |
|     LinkEd> PURGERL MODULE=LIB4SRC                              |
|     LinkEd> ADDRL FROM=LIB4OBJ                                  |
|     LinkEd> EXIT                                                |
___________________________________________________________________

          Figure 2-6.  Updating a Relocatable Object Module in a Relocatable Library 

Alternatively, you can have the compiler (rather than the link editor)
update the relocatable library.  This may be the fastest and easiest
choice if you're compiling MPE V source files that contain several
subroutines and functions.  To do this, use:

     :FTNXL LIB4SRC, RL

(See the HP FORTRAN 77/XL Reference Manual for more information.)



MPE/iX 5.0 Documentation