INFORMIX
DataBlade Developers Kit User's Guide
Chapter 5: Programming DataBlade Module Routines in C
Home Contents Index Master Index New Book

Compiling DataBlade Module Code

BladeSmith generates makefiles for UNIX and Windows platforms. The generated makefiles compile the generated C source, producing a shared object file or dynamic link library, called project.bld, in the source code directory src/C/OS-platform, where OS-platform is the name of the operating system and platform from the Informix registry. For example, src/C/solaris-sparc holds the shared object file compiled on a Sun Solaris Sparc computer.

DataBlade module code requires header files and libraries in the Informix database server installation tree; therefore, to build your DataBlade module, you must add the database server's include and lib directories to your makefile environment.

Important: Only include header files from $INFORMIXDIR/incl/public. Never include or link to files from Informix client libraries.
The makefile requires the INFORMIXDIR environment variable to be set to the Informix database server installation directory. The BINDIR variable in the makefile determines where the shared object file or dynamic link library is written.

BladeSmith creates server, all, and clean targets in the makefile. The server target builds the shared object file. The clean target deletes the shared object file or dynamic link library. The default all target is equivalent to the server target.

Important: When you generate code in BladeSmith, set the Format property of the DataBlade folder to the correct file format for your operating system (UNIX or DOS). The default is DOS. See "Generating Source Files" for more information.

Compiling with Tracing Support

By default, DataBlade modules are compiled without tracing support.

To compile with tracing, you must have generated source code in BladeSmith with tracing. BladeSmith adds the DBDK_TRACE macros and the TraceSet_project procedure to your code if the Tracing property of the Source folder is set to True in BladeSmith's Generate DataBlade dialog box. See "Generating Source Files" for more information.

After you compile with tracing, you must enable tracing for the DataBlade module after you register it in a database. See "Enabling Tracing in a DataBlade Module" for instructions. You must also enable tracing in the database session. See "Enabling Tracing in a Database Session" for instructions.

Compiling on UNIX

On UNIX platforms, you use the generic UNIX.mak makefile. This makefile includes platform-specific makefiles as files named makeinc.platform. To specify the UNIX platform, set the TARGET environment variable to the path and filename of the include file for your platform. Platform-specific files are located in the directory $INFORMIXDIR/incl/dbdk.

Important: Generate code in BladeSmith with the Format property set to UNIX. If you generate code for a UNIX DataBlade module with the DOS file format, you must convert the files to UNIX format before compiling.

To compile and link your DataBlade module shared object file

    1. Copy the generated src/C directory and all of its contents to your UNIX machine.

    2. To compile and link shared objects on a Sun Solaris 2.5 computer using the Sparc compiler, execute the following command at the C shell:

    The project.bld file is created in the src/C/solaris-sparc directory.

Important: For compiling information specific to your operating system, see your machine notes.

Unresolved Symbols

When you link on UNIX, the system displays a list of unresolved symbols. This list can contain these types of unresolved symbols:

Compiling with Debug Support

To debug your DataBlade module while it executes in a database server process, you must build the shared object file with debugging symbols. You can either modify the makefile and add the required compiler flags to the CFLAGS variable, or set the COPTS variable on the make command line.

On Solaris, the following commands build shared object files with debugging symbols from the C shell:

Compiling on Windows NT

For Windows NT, BladeSmith creates two makefiles. The WinNT.mak file is a generic Windows makefile. The project.mak file, where project is the name of your DataBlade module, is a Microsoft Visual C++ 4.2 project makefile.

To compile on Windows NT, you must be logged on to Windows NT as a member of the Informix-Admin group.

The compiled DataBlade module links to sapi.lib. This library resolves the mi_ and ifx_ symbols that the database server uses internally.

Important: Do not link the client DataBlade API library in %INFORMIXDIR%\lib\dmi into the DataBlade module; that library resolves client services instead of database server services.

Compiling with Visual C++

Although the project.mak file is a Microsoft Developer Studio Visual C++ 4.2 file, if you use Visual C++ 5.0, the project.mak file is upgraded when you open it.

The general process for compiling is:

    1. Set the include and library file directories in Microsoft Developer Studio.

    2. Compile and link the project.mak file.

    3. Mark the attributes of the project.bld file as read-only.

The %INFORMIXDIR%\incl\public directory must precede all other Informix include file directories. The %INFORMIXDIR%\lib directory, where %INFORMIXDIR% refers to the database server installation, must be included on the library file directories list.

To set the include files and library file directories

    1. Choose Tools Options.

    2. Click the Directories tab in the Options dialog box.

    3. Select Include files from the Show directories for scroll list.

    4. If the %INFORMIXDIR%\incl\public directory is not on the list, add it:

    a. Double-click the last field in the list (which is empty).

    b. Click the browse button (...).

    c. Select the %INFORMIXDIR%\incl\public directory from the Open dialog box.

    d. Click OK.

    5. Select the %INFORMIXDIR%\incl\public directory.

    6. Click the Move Item Up button to relocate the directory above any other Informix include directories.

    7. Select Library files in the Show directories for scroll list.

    8. If the %INFORMIXDIR%\lib directory is not on the list, add it:

    a. Double-click the last field in the list (which is empty).

    b. Click the browse button (...).

    c. Select the %INFORMIXDIR%\lib directory from the Open dialog box.

    d. Click OK.

    9. Click OK to exit the Options dialog box.

To compile and link a dynamic link library using Visual C++

    1. Using Windows Explorer, copy the src\c directory and all of its contents to the Windows NT machine on which an Informix database server is installed.

    2. Open your project.mak file in Microsoft Developer Studio Visual C++.

    3. Choose Build Set Active Configuration.

    4. Select a version of the project in the Set Active Project Configuration dialog box:

    5. Click OK.

    6. Choose Build Rebuild All to compile.

Microsoft Developer Studio creates both a Release and a Debug directory under the src\c directory to hold the release version and the debug version, respectively, of the dynamic link library.

To mark the attributes of the resulting project.bld file as read-only, use Microsoft Windows Explorer to open the file's Properties dialog box, then check the Read-only check box. The Informix database server cannot load a dynamic link library unless its attributes are set to read-only.

Compiling from the MS-DOS Command Prompt

Use the WinNT.mak file generated by BladeSmith to build your DataBlade module code from the MS-DOS command prompt.

To compile and link the DataBlade module dynamic link library

    1. Using Windows Explorer, copy the src\c directory and all of its contents to the Windows NT computer on which an Informix database server is installed.

    2. Set the INCLUDE environment variable to %INFORMIXDIR%, add %INFORMIXDIR%\bin to the PATH environment variable, and add %INFORMIXDIR%\lib to the LIB environment variable.

    3. To set the INCLUDE, LIB, and PATH environment variables to include Microsoft Developer Studio Visual C++ default compiler libraries and header files, execute the following command from the bin directory of your Microsoft Developer Studio Visual C++ installation:

    4. Execute the following command from the src\c directory:

    The project.bld file is created in the src\c\WinNT-i386 directory.




DataBlade Developers Kit User's Guide, version 3.6
Copyright © 1998, Informix Software, Inc. All rights reserved.