To build a DLL from a particular source code module, the code is compiled in a similar manner to that used for any other Presentation Manager application code. However, use of the /Ge- option will cause the C Set/2 compiler to produce a DLL module.
CC /L- /G3 /Ti+ /Gm+ /Ge- MYDLL OS2386.LIB MYDLL.DEF
This command sequence instructs the compiler to take the file MYPROG.C, to compile and link edit it to produce a dynamic link library named MYPROG.DLL, and to use the file named MYPROG.DEF as input to the linking process. Use of the /Gm+ option enables multithreading, and use of the /Ge- option directs C Set/2 to produce a DLL module.
A sample module definition file for use when creating a DLL is shown in Figure "Sample Module Definition File to Create a DLL":
The following rules apply to module definition files when used to create dynamic link libraries:
The DLL module must be copied to a directory referenced by the LIBPATH statement in CONFIG.SYS. This is typically the C:\OS2\DLL directory, although another directory may be used if so desired.