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
- Code your DLL source files and define functions you wish
to export using _Export, #pragma export, or
__declspec(dllexport).
- Compile the source code (at least one file must be
compiled with /Ge-).
- Link the object modules using icc with
/Ge-. icc will call ILIB to produce a
LIB import library and a EXP export object.
- Include the LIB import library when you link a module
which calls the DLL.
Building a DLL - Method 2
- Code your DLL source files.
- Compile the source code (at least one file must be
compiled with /Ge-).
- 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.
- Invoke ILIB with the /geni option and pass it the DEF
file. ILIB generates a LIB import library and an EXP
export object.
- Link the DLL and include the EXP object.
- 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.