Build and use a DLL

You can use the method that is shown in Figure 1 to build a DLL. To build a DLL, the code that you compile must contain symbols which indicate that they are exported. You can use the compiler option EXPORTALL or the #pragma export directive to indicate symbols in your C or C++ code that are to be exported. For C++, you can also use the _Export keyword.

When you build the DLL, the bind step generates a DLL and a file of IMPORT control statements which lists the exported symbols. This file is known as a definition side-deck. The binder writes one IMPORT control statement for each exported symbol. The file that contains IMPORT control statements indicates symbol names which may be imported and the name of the DLL from which they are imported.

Figure 1. Build a DLL
REQTEXT

You can use the method that is shown in Figure 2 to build an application that uses a DLL. To build a program which dynamically links symbols from a DLL during application run time, you must have C++ code, or C code that is compiled with the DLL option. This allows you to import symbols from a DLL. You must have an IMPORT control statement for each symbol that is to be imported from a DLL. The IMPORT control statement controls which DLL will be used to resolve an imported function or variable reference during execution. The bind step of the program that imports symbols from the DLL must include the definition side-deck of IMPORT control statements that the DLLs build generated.

The binder does not take an incremental approach to the resolution of DLL-linkage symbols. When binding or rebinding a program that uses a DLL, you must always specify the DYNAM(DLL) option, and must provide all IMPORT control statements. The binder does not retain these control statements for subsequent binds.

Figure 2. Build an application that uses a DLL
REQTEXT