Create Module Definition Files ( OS/2, Windows)

VisualAge C++ does not use module definition (.def) files in the same way that earlier versions did.
To build a DLL with previous versions of VisualAge C++ for OS/2 3.0 and IBM C and C++ Compilers 3.6, you had to create a module definition file and supply it to the linker.
In previous versions of VisualAge for C++ for Windows version 3.5 and IBM C and C++ Compilers 3.6, supplying a module definition file was optional.

The primary purpose of a .def file was to list the symbols imported or exported by the module being built. You could also specify other options that affected how the linker created the target module. Module definition files are no longer required. Generally, you should have no reason to create one.

However, you may want a .def file as an aid in migrating DLLs from earlier versions of VisualAge C++, or to extract from an existing DLL a list of the exported symbols.
These files may be useful because they show mangled C++ symbol names.

The names are also decorated on Windows. The ilib utility cannot determine the calling convention of functions in a library from by looking at the library file alone, because the linkage is specified only in the source code or in a .def file. Therefore, it assumes all exported functions have the default calling convention, _Optlink.

You can use the ilib command to create a module definition file. Follow the steps listed below:

  1. Have an existing DLL or object modules that were generated from C or C++ sources that export symbols explicitly, or a combination of objects modules and a DLL.
  2. In a VisualAge C++ command line window, open a working directory.
  3. Issue the ilib command. Use the /gendef:fileName option. If you omit the file name, the module definition file has the same base name as the first input file and the extension .def. The short form /gd is equivalent to /gendef. Also list the input DLL or object modules on the command line.

For example, the following command creates the module definition file winner.def from the DLL winner.dll. If a file named winner.def already exists, it is replaced.

ilib /gd:winner.def winner.dll


Static and Dynamic Link Libraries
.def and .exp Files are Obsolete
Maintaining Libraries
Calling Conventions


Build Dynamic Link Libraries
Build Modules That Use DLLs
Export Symbols from a DLL


The ilib Command