Using an Executable Library [ HP Link Editor/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Link Editor/XL Reference Manual
Using an Executable Library
Routines in executable libraries can be shared by many programs; each
program uses the same physical copy of code. Though you name executable
libraries using the link editor, these libraries are not searched until
the executable program file is loaded for execution. (The loader
searches the executable libraries, resolving external references, much
like the link editor searches relocatable libraries.)
The next three sections show how to create and maintain executable
libraries and how to name an executable library to be searched at run
time. See the last section in this chapter, "Sample Programs", for
listings of the source files used in the examples.
Creating an Executable Library
Figure 2-7 shows how to build an executable library and how to add a
module to it at the same time. The link editor BUILDXL command creates
the executable library, LIBXL. The ADDXL command adds the relocatable
object file, EX2BOBJ, to LIBXL.
___________________________________________________________________
| |
| :FTNXL EX2BSRC,EX2BOBJ |
| :LINKEDIT |
| LinkEd> BUILDXL XL=LIBXL |
| LinkEd> ADDXL FROM=EX2BOBJ |
| LinkEd> EXIT |
___________________________________________________________________
Figure 2-7. Creating an Executable Library and Adding a Module To It
Alternatively, when you add relocatable object modules to an executable
library, you can merge several of them into one module. Figure 2-8 shows
how to merge five relocatable object files (LIB10BJ, LIB2OBJ, LIB3OBJ,
LIB4OBJ, and LIB5OBJ) into one executable module in the library. (The
name of the new executable module is the source file name of the first
relocatable object file added, LIB1SRC.)
_______________________________________________________________________
| |
| :FTNXL LIB1SRC,LIB1OBJ |
| :FTNXL LIB2SRC,LIB2OBJ |
| :FTNXL LIB3SRC,LIB3OBJ |
| :FTNXL LIB4SRC,LIB4OBJ |
| :FTNXL LIB5SRC,LIB5OBJ |
| :LINKEDIT |
| LinkEd> BUILDXL XL=LIBXL |
| LinkEd> ADDXL FROM=LIB1OBJ,LIB2OBJ,LIB3OBJ,LIB4OBJ,LIB5OBJ;MERGE|
| LinkEd> EXIT |
_______________________________________________________________________
Figure 2-8. Creating an Executable Module From Several Relocatable Object Files
Searching an Executable Library
Figure 2-9 shows how to name an executable library to be searched at run
time. The :LINK command links the relocatable object file, EX2AOBJ,
producing the executable program file, EX2PROG. The XL= option names the
executable library, LIBXL, to search at run time.
___________________________________________________________________
| |
| :LINK FROM=EX2AOBJ;TO=EX2PROG;XL=LIBXL |
___________________________________________________________________
Figure 2-9. Naming an Executable Library To Search
Updating an Executable Library
Figure 2-10 shows how to replace an executable module in an executable
library. The executable module, EX2BOBJ (created in figure 2-7), is
replaced by a newly-compiled version. Once the HP FORTRAN 77 source
file, EX2BSRC, is recompiled (line 1), the link editor XL command on the
third line sets the default executable library to LIBXL. To update the
existing executable module, the old version is purged and a new one
added. The PURGEXL command purges the existing module, EX2BSRC, from the
library. (The name of the module in an executable library is the same as
its source file name, EX2BSRC, unless the $RLFILE compiler option is
used.) The ADDXL command then adds the updated relocatable object file,
EX2BOBJ, to the library.
___________________________________________________________________
| |
| :FTNXL EX2BSRC,EX2BOBJ |
| :LINKEDIT |
| LinkEd> XL XL=LIBXL |
| LinkEd> PURGEXL MODULE=EX2BSRC |
| LinkEd> ADDXL FROM=EX2BOBJ |
| LinkEd> EXIT |
___________________________________________________________________
Figure 2-10. Updating an Executable Module in an Executable Library
MPE/iX 5.0 Documentation