Steps for Building a DLL in Windows

Building a Dynamic Link Library (DLL) involves the use of the IBM Library Manager (ILIB) and the IBM Linker (ILINK). There are basically two ways to build a DLL, one which requires changes to your source code and one which does not.

Building a DLL - Method 1

  1. Code your DLL source files and define functions you wish to export using _Export, #pragma export, or __declspec(dllexport).
  2. Compile the source code (at least one file must be compiled with /Ge-).
  3. Link the object modules using icc with /Ge-. icc will call ILIB to produce a LIB import library and a EXP export object.
  4. Include the LIB import library when you link a module which calls the DLL.

Building a DLL - Method 2

  1. Code your DLL source files.
  2. Compile the source code (at least one file must be compiled with /Ge-).
  3. Create a DEF file using CPPFILT. Run CPPFILT on the objects to produce an export listing, use /B and /P options. Comment out or remove any function names in the CPPFILT output that you do not want to export. Create a skeleton DEF file with a LIBRARY and an EXPORTS statement. imbed the edited CPPFILT output under the EXPORTS statement.
  4. Invoke ILIB with the /geni option and pass it the DEF file. ILIB generates a LIB import library and an EXP export object.
  5. Link the DLL and include the EXP object.
  6. Include the LIB import library when you link a module which calls the DLL.

Each of these steps, and variations, are discussed in more detail in the following sections.