Finally, for each of your class libraries, you should create an import library that can be used by client programs (or by other class libraries that use your classes) to resolve the references to your classes.
Here is an example illustrating all of the steps required to create a class library ("abc.dll") that contains the three classes "A", "B", and "C".
For AIX written in C:
xlc -I. -I$SOMBASE/include -c a.c xlc -I. -I$SOMBASE/include -c b.c xlc -I. -I$SOMBASE/include -c c.c xlc -I. -I$SOMBASE/include -c initfunc.c
For AIX written in C++:
xlC -I. -I$SOMBASE/include -c a.C xlC -I. -I$SOMBASE/include -c b.C xlC -I. -I$SOMBASE/include -c c.C xlC -I. -I$SOMBASE/include -c initfunc.C
For OS/2 written in C:
icc -I. -I%SOMBASE%\include -Ge- -c a.c icc -I. -I%SOMBASE%\include -Ge- -c b.c icc -I. -I%SOMBASE%\include -Ge- -c c.c icc -I. -I%SOMBASE%\include -Ge- -c initfunc.c
Note: The "-GE" option is used only with the IBM compiler. It indicates that the object files will go into a DLL.
For OS/2 written in C++:
icc -I. -I%SOMBASE%\include -Ge- -c a.cpp icc -I. -I%SOMBASE%\include -Ge- -c b.cpp icc -I. -I%SOMBASE%\include -Ge- -c c.cpp icc -I. -I%SOMBASE%\include -Ge- -c initfunc.cpp
Note: The "-Ge" option is used only with the IBM compiler. It indicates that the object files will go into a DLL.
For AIX:
sc -sexp a.idl b.idl c.idl
For OS/2:
sc -sdef a.idl b.idl c.idl3.
For AIX, create a file "abc.exp" from "a.exp", "b.exp", and "c.exp". Do not include the initialization function (SOMInitModule) in the export list.
For OS/2, create a file "abc.def" from "a.def", "b.def", and c.def". Include the initialization function (SOMInitModule) in the export list, so that all classes will be initialized automatically, unless your initialization function does not need arguments and you explicitly invoke it yourself from an OS/2 DLL initialization routine.
For AIX:
ld -o abc.dll -bE:abc.exp -e SOMInitModule -H512 -T512 \ a.o b.o c.o initfunc.o -lc -L$SOMBASE/lib -lsomtk
The -o option assigns a name to the class library ("abc.dll"). The -bE: option designates the file with the appropriate export list. The -e option designates SOMInitModule as the initialization function. The -H and -T options must be supplied as shown; they specify the necessary alignment information for the text and data portions of your code. The -l options name the specific libraries needed by your classes. If your classes make use of classes in other class libraries, include a -l option for each of these also. The ld command looks for a library named "lib<x>.a", where <x> is the name provided with each -l option. The -L option specifies the directory where the "somtk" library resides.
For OS/2:
set LIB=%SOMBASE%\lib;%LIB% link386 /noi /packd /packc /align:16 /exepack \ a.obj b.obj c.obj initfunc.obj, abc.dll,,os2386 somtk, \ abc.def
If your classes make use of classes in other class libraries, include the names of their import libraries immediately after "somtk" (before the next comma). 5.
For AIX:
ar ruv libabc.a abc.exp Note the use of the ".exp" file, not a ".o" file
The first filename ("libabc.a") specifies the name to give to the import library. It should be of the form "lib<x>.a", where <x> represents your class library. The second filename ("abc.exp") specifies the exported symbols to include in the import library.
Caution: Although AIX shared libraries can be placed directly into an archive file ("lib<x>.a"), this is not recommended! A SOM class library should have a corresponding import library constructed directly from the combined export file.
For OS/2:
implib /noi abc.lib abc.def
The first filename ("abc.lib") specifies the name for the import library and should always have a suffix of ".lib". The second filename ("abc.def") specifies the exported symbols to include in the import library.
Note: SOMInitModule should be included in the <x>.dll but not in <x>.lib. If you are using an export file that contains the symbol SOMInitModule, delete it first; SOMInitModule should not appear in your import library because it need not be exported. SOMInitModule should be included when creating your file <x>.dll because all classes in the <x>.dll will be initialized.