Loading DLLs and .DEF files
Previous Topic  Next Topic 

The -r compile time option provides the mechanism to load the function definitions for external TE DLL library functions.  However it is not necessary to always load the actual DLL libary when compiling an application,   instead the compiler can be instructed to use a .DEF file instead which is simply a text file containing the function definitions from the actual DLL.    If a .DEF file is specified then the compiler does not need to load the entire DLL in order to access the function definitions - it will simply read them from ythe .DEF file instead.


This has two advantages over loading the full DLL at compile time:


a) Since the full DLL does not need to be loaded it makes the compilation faster.

b) Sometimes a DLL will automatically attempt to load other DLLs which may only be present on the run-time machine and not on the machine where compilation is taking place (E.g. the ACULUB DLLs libaries (sw_lib.dll, cc_lib.dll etc)).


By default there is one large definition file (TCL.DEF) that holds the definitions for all of the TE Standard Library Set.    The compiler will search for this definition file in the current directory first, then it will search in the directory where the TCL.EXE program resides (this is where the TCL.DEF file will reside by default).        By searching the currect directory first this allows the default TCL.DEF file to be overridden by a specific TCL.DEF file in the current directory.


Therefore in general it is not necessary to load any of the TE Standary Library Set DLLs at compile time since usually the compiler will load the default TCL.DEF file which will contain these function definitions.           If this is not the behaviour that is required then the -n option can be specified which prevents the compiler loading the default TCL.DEF file automatically (in which case individual DLL or .DEF files must be specified for the TE Standary Library Set  functions.


A definition file is a text file will the following format:


<DLL library  name 1>

<DLL compilation date>

<Number of Functions>

<Function 1 Minimum arguments>,<Maximum Arguments>,<UniqueFunction ID>,<Number of Synonyms>,<Function name1>[,function name 2[,...]]>

<Function 2 Minimum arguments>,<Maximum Arguments>,<UniqueFunction ID>,<Number of Synonyms>,<Function name1>[,function name 2[,...]]>

...

[

<DLL library name 2>

<DLL compilation date>

<Number of Functions>

<Function 1 Minimum arguments>,<Maximum Arguments>,<UniqueFunction ID>,<Number of Synonyms>,<Function name1>[,function name 2[,...]]>

<Function 2 Minimum arguments>,<Maximum Arguments>,<UniqueFunction ID>,<Number of Synonyms>,<Function name1>[,function name 2[,...]]>

...

...]


For example,  below is the definition file for the CXSEM.DLL library:


cxsem

Nov 10 2006 11:39:08

4

1,1,115,1,sem_test

1,1,116,1,sem_set

1,-1,117,1,sem_clear

1,-1,16,1,sem_clrall



(Note that a maximum or minimum number of arguments of -1 means that a variable number of arguments is allowed).


Definition files can be specified in the -r option by specifying the full name of definition file.   For example:


TCL -rCXTERMX.DEF;C:\DEFFILES\CXSEM.DEF MyProg


It is OK to mix DLLs and .DEF files in the -r option library list.     


Note that if the same function name is defined more than once either in multiple DLL libaries or .DEF files then the one with the lowest unique function ID will be the one that is used.   


Also if two functions have the same unique function ID then the one that was defined last in the -r option will overwrite the previous definition and will be the one that is used.