Creating C-Extensions

Custom C-Extensions must be provided to the runtime system as Shared Objects (.so) on UNIX™, and as Dynamically Loadable Libraries (.DLL) on Windows®.

In order to create a C-Extension, you must:

  1. Setup you C compiler environment.
  2. Modify your C source modules by including the fglExt.h header file:
    #include "f2c/fglExt.h"
  3. Define the list of user functions in the C interface file, by including the fglExt.h header file.
  4. Compile the C sources and C interface file, the link these object files to create a shared object (.so or .DLL)

To setup the C compiler environment: On a UNIX/Linux® operating system, check the cc or gcc command. On a Windows, you need a Visual C++ version compatible with the FGL package. It is mandatory to setup the Visual C++ environment by executing the vcvars64.bat command file provided in the Visual C++ installation directory.

Note:

When migrating from IBM® Informix® 4GL, it is possible that existing C-Extension sources include Informix specific headers like sqlhdr.h or decimal.h. Replace the Informix 4GL header files by fglExt.h header file.

In order to compile and create the shared object of your C-Extension library, use the fglmkext command line tool:
fglmkext -o myext.so module_a.c module_b.c

The fglmkext command line tool contains platform-specific C compiler and linker options required to build a C Extension library.