Migrating C-files (Functions, Libraries) from the Existing Project to Lycia

Overview

Example

Header Files for the ESQL/C Data Type Definitions

Overview

The C Interface has been created for you to call C functions, which come in shared / static libraries, from Lycia 4GL application code. Using the C interface, you can include standard or custom C libraries in your application using the wrapper functions.

Function parameters and returned values are managed on the runtime stack using pop and push operations. Ensure you pop and push the exact number of parameters and returned values expected by the caller to avoid a fatal stack error at runtime.

To include the C code in the 4GL program, do the following:

Note: The C code created using the C Interface is typically platform-specific, so keep that in mind when migrating your application to a different operating system. Also, the definition of C data types varies depending on the processor architecture (32 bits or 64 bits).

Ensure that the functions defined in your C Interface do not conflict with existing program functions. Conflicts can result in compiler or runtime errors.

Example

Step 1. Add the C source files, header files, and ESQL/C files to your Workspace:

Step 2. Create a static C library in your project by right-clicking the Project context menu and selecting the Create New Static C Library option:

Step 3. Name the library and press Enter:

Your created library will now appear as a part of the project in FGL Project Explorer:

Also, it will receive its own .fgltarget file (displayed in the source folder of your program in the Workpace) and will therefore become a build target.

Note: In case the changes don’t get displayed right away, click the Update FGL Targets Cache button, located in the FGL Project Explorer’s header.

Step 4. Right-click the library, select Add Existing File, and then - Add C Source File:

Step 5. In the dialog that will appear in the upper part of the window, find a file you need to add to the library, and select it:

Tip: The .. option in the dialog will move you to the directory that is a parent of a current one.

Step 6. Right-click the program, and select the Add Existing Library option:

Step 7. In the dialog that will open in the upper part of the window, select the library / libraries by ticking their boxes, and click OK:

After that, right-click your program and select the Build/Deploy option to link all the resources.

 

Return to top

Header Files for the ESQL/C Data Type Definitions

To use complex data files in a C Interface, include C header files (.h) that contain the definitions of C structures.

For compiling a program with C Interface using the data types such as DECIMAL, DATETIME, INTERVAL, BYTE, or TEXT, you need IBM® Informix® ESQL/C data type structure definitions such as dec_t, dtime_t, intrvl_t, as well as macros like TU_ENCODE(). These definitions are unnecessary if you use standard C types, such as short, int, or char[].

The definition of the ESQL/C structures like dec_t are provided in individual header files, under the $LYCIADIR/include/ directory: decimal.h, datetime.h, locator.h.

 

Return to top

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.