16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

c89, cc, and c++<br />

78 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference<br />

DLL (Dynamic Link Library)<br />

A DLL is a part of a program that is not statically bound to the<br />

program. Instead, linkage to symbols (variables and functions) is<br />

completed dynamically at execution time. DLLs can improve<br />

storage utilization, because the program can be broken into smaller<br />

parts, and some parts may not always need to be loaded. DLLs can<br />

improve maintainability, because the individual parts can be<br />

managed and serviced separately.<br />

In order to create a DLL, some symbols must be identified as being<br />

exported for use by other parts of the program. This can be done<br />

with the z/<strong>OS</strong> XL C/C++ #pragma export compiler directive, or by<br />

using the z/<strong>OS</strong> XL C/C++ EXPORTALL compiler option. If during<br />

the link-editing phase some of the parts have exported symbols, the<br />

executable which is created is a DLL. In addition to the DLL, a<br />

definition side-deck is created, containing link-editing phase<br />

IMPORT control statements which name those symbols which were<br />

exported by the DLL. In order for the definition side-deck to be<br />

created, the DLL link editor option must be specified. This definition<br />

side-deck is subsequently used during the link-editing phase of a<br />

program which is to use the DLL. See the file.x operand under<br />

Operands on page 83 for information on where the definition<br />

side-deck is written. In order for the program to refer to symbols<br />

exported by the DLL, it must be compiled with the DLL compiler<br />

option.<br />

Example: To compile and link a program into a DLL, you could<br />

specify:<br />

c89 -o outdll -W c,exportall -W l,dll file.c<br />

To subsequently use file.x definition side-decks, specify them along<br />

with any other file.o object files specified for c89/cc/c++ link-editing<br />

phase.<br />

Example: To accomplish this task, you could specify:<br />

c89 –o myappl –W c,dll myappl.c outdll.x<br />

In order to run an application which is link-edited with a definition<br />

side-deck, the DLL must be made available (the definition side-deck<br />

created along with the DLL is not needed at execution time). When<br />

the DLL resides in the z/<strong>OS</strong> <strong>UNIX</strong> file system, it must be in either<br />

the working directory or in a directory named on the LIBPATH<br />

environment variable. Otherwise it must be a member of a data set<br />

in the search order used for MVS programs.<br />

Note: For non-DLL C++ compiles, a dummy definition side file will<br />

be allocated to prevent the binder from issuing a warning<br />

message. If you do want the binder to issue a warning<br />

message when an exported symbol is encountered, specify<br />

the DLL=NO option for the link-editing phase; for example:<br />

c++ -o outfile -W l,dll=no file.C<br />

IPA (interprocedural analysis)<br />

IPA optimization is independent from and can be used in addition to<br />

the c89/cc/c++ optimization level options (such as –O). IPA<br />

optimization can also improve the execution time of your<br />

application. IPA is a mechanism for performing optimizations across

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!