### Compile and Link Your DLL in Separate Steps

To compile and link your DLL in separate steps:

- Invoke the compiler with the /C+ option to compile your source files without linking them, and the /Ge- option to specify your output as a DLL
- If you did not indicate in your source files which functions and data you wish to export, create a module definition file to provide that information.
- Pass your object files, library files, and module definition file (if applicable) to ILIB to create an import library (.LIB) and an export object (.EXP).
  Pass your object files, library files and module definition file (if applicable) to ILIB to create an import library (.LIB).
- Link them, giving the following information to the IBM C and C++ Compilers linker:
  - The compiled object files for the DLL;
  - The name to give the DLL;
  - The C libraries to use;
  - The name of the EXP file generated by ILIB.

> Note: The compiler includes information in the object files on the C libraries you indicated by the compiler options that control code generation.These libraries are automatically used at link time. You do not need to specify C runtime libraries on the linker command line unless you want to override the ones you chose at compile time.

Example:
For example, the following commands compile the source files mydlla.c and mydllb.c and link the resulting object files with the single-thread, statically linked C libraries using the definition file mydll.def, to create the DLL finaldll.dll.

       icc  /C+ /Ge- mydlla.c mydllb.c

       ILIB /geni:finaldll.lib mydlla.obj mydllb.obj

    ILINK mydlla.obj mydllb.obj mydll.exp /OUT:finaldll.dll
    ILINK mydlla.obj mydllb.obj /OUT:finaldll.dll

If your DLL contains C++ code that uses templates, there are additional considerations. The preferred method is to use the icc command to compile and to invoke the linker for you.

Create a DLL - An Overview