|
To compile a C UDR, use a C compiler to compile the source file (.c file extension) into an object file (.o file extension) and create a shared-object file that contains the object file.
Tip: The Informix BladeSmith development tool, which is part of the DataBlade Developers Kit, automatically generates makefiles to compile the DataBlade module code that it generates. It creates a makefile for both the UNIX (with a .mak extension) and Windows (with a .dsw extension) platforms.A makefile automates compilation of C UDRs.To compile a C UDR into a shared-object file (with a .bld extension) you only have to run the appropriate makefile. For more information, see the "DataBlade Developers Kit User's Guide."
Compiling Options
Use the C compiler to compile a C UDR. Include the following compiler options:
On a Solaris system, the following sample command compiles the C UDR in the abs.c source file:
The following command is a sample of how to compile a C UDR called abs.c for the Windows NT platform:
For C UDRs, you create a shared-object file to hold the compiled UDRs. This file resides in a directory on the server computer. Each UDR must have a unique name within the shared-object file.
On UNIX systems, a shared-object file is often called a shared library. On Solaris systems, shared-object files have the .so file extension.
On Windows NT systems, a shared-object file is called a dynamic link library (DLL). DLLs usually have the .dll file extension.
When the database server executes an SQL statement that contains a UDR, it loads in memory the shared-object file in which the UDR executable code resides. It determines which shared-object file to load from the externalname column of the sysprocedures system catalog table. The CREATE FUNCTION or CREATE PROCEDURE statement makes a row in this table for a particular UDR when it registers the routine.
The following steps outline how to create a shared-object file for a C UDR:
Important: If a shared-object file has write permission set to all, the database server issues error -9793 and writes a message in the log file when someone tries to execute any UDR in the shared object.
For general information on how to create a shared-object file, see the chapter on how to run a user-defined routine in Extending Informix Dynamic Server 2000. For more information on how the database server loads a shared-object file, see Executing a User-Defined Routine.
The following steps show how to create a shared library called abs.so on a Solaris system.
The following steps show how to create a DLL called abs.dll on a Windows NT system.