Steps for using an implicitly loaded DLL in your simple DLL application

About this task

Perform the following steps to use an implicitly loaded DLL (sometimes called a load-on-call DLL) in your simple DLL application:

Procedure

  1. Write your code as you would if the functions were statically bound.
  2. Compile as follows:
    • Compile your non-XPLINK application C source files with the following compiler options:
      • DLL
      • RENT
      • LONGNAME
      These options instruct the compiler to generate special code when calling functions and referencing external variables. If you are using z/OS® UNIX, RENT and LONGNAME are already the defaults, so compile as:
      c89 -W c,DLL ...
    • Compile your C++ source files normally. A C++ application is always DLL code.
    • For XPLINK, compile your C and C++ source files with the XPLINK compiler option. XPLINK compiled C and C++ source is always DLL code.
  3. Bind your object modules as follows:
    • If you are using z/OS Batch, use the IBM-supplied procedure when you bind your object modules. You must chose the appropriate procedures for XPLINK or non-XPLINK.
    • If you are not using the IBM-supplied procedure, specify the RENT, DYNAM(DLL), and CASE(MIXED) binder options when you bind your object modules.
      Note: XPLINK and non-XPLINK use different z/OS Language Environment® libraries, and XPLINK requires the C runtime library side-deck for resolution of C runtime library function calls. For more information, see "Planning to Link-Edit and Run" in z/OS Language Environment Programming Guide.
    • If you are using z/OS UNIX specify the following option for the bind step for c89 or c++.
      c89 -W l,DLL
      If you are using XPLINK, also add the XPLINK option, so that the c89 utility will use the correct z/OS Language Environment libraries and side-decks:
       c89 -W l,DLL,XPLINK ...
    • Include the definition side-deck from the DLL provider in the set of object modules to bind. The binder uses the definition side-deck to resolve references to functions and variables defined in the DLL. If you are referencing multiple DLLs, you must include multiple definition side-decks.
      Note: Definition side-decks can not be resolved by automatic library call (autocall) processing, so you must specify an INCLUDE statement to explicitly include a definition side-deck for each referenced DLL.

Results

The following code fragment illustrates how an application can use the DLL described previously. Compile normally and bind with the definition side-deck provided with the TRIANGLE DLL.

  extern int getarea();  /* function prototype */
  main () {
      ...
      getarea();         /* imported function reference */
      ...
  }

See Figure 1 for a summary of the processing steps required for the application (and related DLLs).