Building DLLs

Note: This topic does not describe all of the steps that are required to build a DLL. It only describes the prelink step. For a complete description of how to build DLLs, see z/OS XL C/C++ Programming Guide.

Except for the object modules you require for creating the DLL, you do not require additional object modules. The prelinker automatically creates a definition side-deck that describes the functions and the variables that DLL applications can import.

Note: Although some C applications may need only the linkage editor to link them, all DLLs require either the use of the binder with the DYNAM(DLL) option, or the prelinker before the linkage editor.

When you build a DLL, the prelinker creates a definition side-deck, and associates it with the SYSDEFSD ddname. You must provide the generated definition side-deck to all users of the DLL. Any DLL application which implicitly loads the DLL must include the definition side-deck when they prelink.

Example: An example of a definition side-deck generated by the prelinker when prelinking a C object module:
IMPORT CODE 'BASICIO'   bopen
IMPORT DATA 'BASICIO'   bclose
IMPORT DATA 'BASICIO'   bread
IMPORT DATA 'BASICIO'   bwrite
IMPORT DATA 'BASICIO'   berror

You can edit the definition side-deck to remove any functions or variables that you do not want to export. For instance, in this example, if you do not want to expose function berror, remove the control statement IMPORT DATA 'BASICIO' berror from the definition side-deck.

Note: You should also provide a header file that contains the prototypes for exported functions and external variable declarations for exported variables.
Example: An example of a definition side-deck generated by the prelinker when prelinking a C++ object module:
IMPORT CODE 'TRIANGLE' getarea__8triangleFv
IMPORT CODE 'TRIANGLE' getperim__8triangleFv
IMPORT CODE 'TRIANGLE' __ct__8triangleFv

You can edit the definition side-deck to remove any functions and variables that you do not want to export. For instance, in this example, if you do not want to expose getperim(), remove the control statement IMPORT CODE 'TRIANGLE' getperim__8triangleFv from the definition side-deck.

The definition side-deck contains mangled names, such as getarea__8triangleFv. If you want to know what the original function or variable name was in your source module, look at the compiler listing created. Alternatively, use the CXXFILT utility to see both the mangled and demangled names. For more information on the CXXFILT utility, see Filter utility.

Note: You should also provide users of your DLL with a header file that contains the prototypes for exported functions and extern variable declarations for exported variables.

The prelinker NODYNAM option must not be in effect when building DLLs.

Linking your code

When you link your code, ensure that you specify the RENT or REUS(SERIAL) options.