Compiling UDFs on Unix

By: Borland Staff

Abstract: Example for compiling a UDF under Solaris

Problem:
There is no example of compiling UDF on Unix platforms.

Solution:
 Here is an example of compiling UDFs on Solaris.

1.  Take the sample udflib.c from /usr/interbase/examples/v4/udflib.c 
     to a working directory.

2.  compile & link:
     cc -G Bdynamic -lgdsshr -o funclib udflib.c

3.  Connect to a database & declare the entry point.
     connect  employee.gdb;
     Declare external function trim
               cstring(256)
               returns char (80) free_it
               entry_point "fn_trim" module_name "funclib";

Note:  the entry point can be hardcoded with the path or not like 
the case above.  For the above example it will search in the 
LD_LIBRARY_PATH for "funclib".  Solaris will look for the function libary in what's
specified in the  LD_LIBRARY_PATH environment variable.  For HP, it's SHLIB_PATH.
One can view what's set for  LD_LIBRARY_PATH 
with command "setenv".  The following example is hardcoding the 
path to "funclib":

Declare external function trim
       cstring(256)
       returns char (80) free_it
       entry_point "fn_trim" module_name "/temp/funclib";



Server Response from: ETNASC03