Building export files

The SOM Compiler provides an "exp" emitter for AIX and a "def" emitter for OS/2 to produce the necessary exported symbols for each class. For example, to generate the necessary exports for a class "A", issue the sc or somc command with one of the following -s options. (For a discussion of the sc or somc command and options, see "Running the SOM Compiler" in Chapter 4, "SOM IDL and the SOM Compiler.")

For AIX, this command generates an "a.exp" file:

   sc -sexp a.idl

For OS/2, this command generates an "a.def" file:

   sc -sdef a.idl

Typically, a class library contains multiple classes. To produce an appropriate export file for each class that the library will contain, you can create a new export file for the library itself by combining the exports from each "exp" or "def" file into a single file. Following are examples of a combined export "exp" file for AIX and a combined "def" file for OS/2. Each example illustrates a class library composed of three classes, "A", "B", and "C".

AIX "exp" file:

   #! abc.dll
   ACClassData
   AClassData
   ANewClass
   BCClassData
   BClassData
   BNewClass
   CCClassData
   CClassData
   CNewClass

OS/2 "def" file:

   LIBRARY abc INITINSTANCE
   DESCRIPTION 'abc example class library'
   PROTMODE
   DATA MULTIPLE NONSHARED LOADONCALL
   EXPORTS
     ACClassData
     AClassData
     ANewClass
     BCClassData
     BClassData
     BNewClass
     CCClassData
     CClassData
     CNewClass

Other symbols in addition to those generated by the "def" or "exp" emitter can be included if needed, but this is not required by SOM. One feature of SOM is that a class library needs no more than three exports per class (by contrast, many OOP systems require externals for every method as well). One required export is the name of a procedure to create the class (<className>NewClass), and the others are two external data structures that are referenced by the SOM bindings.


[Back: Types of class libraries]
[Next: Specifying the initialization function]