4. Embedded SQL for Fortran : Preprocessor Operation : How Embedded SQL Programs are Linked : Link Precompiled Forms
 
Share this page                  
Link Precompiled Forms
The Forms-based Application Development Tools User Guide and the Fortran Variables and Data Types (see page Fortran Variables and Data Types) section in this chapter, discuss how to declare a precompiled form to the FRS. In order to use such a form in your program, you must also follow the steps described below depending on your operating system.
UNIX
To link a precompiled form
1. In VIFRED, select a menu item to compile a form. VIFRED then creates a C language source file in your directory that contains a description of the form. Select a name for the file.
2. Before compiling and linking this file with your Embedded SQL program, make the form name, or formid, contained therein consistent with the way Fortran stores external symbols.
When you compile the Fortran source file generated from your Embedded SQL program, the Fortran compiler appends an underscore to all external symbols. Some Fortran compilers also truncate names to six characters before appending the underscore. Because the formid is an external symbol, it too has an underscore appended and may be truncated. In order to resolve this link-time inconsistency, you must change the formid as it appears in the file created by VIFRED as instructed in Step 3.
3. Edit the C source file created by VIFRED that contains your compiled form. When you invoke the editor, find the line at the end of the file that begins with"FRAME * formid" where formid is the name of the form. Append an underscore to formid and truncate the name, if necessary. The following example shows the relevant lines of a C source file created by VIFRED where "empfrm" is the formid:
     ...

FRAME * empfrm = {
      &_empfrm, };
Modify the file to append the required underscore, as follows:
     ...

FRAME * empfrm_ = {
      &_empfrm, };
This example assumes that your compiler does not truncate external symbols.
Note:  You do not need to make changes to the declarations containing the formid in your Embedded SQL program. The Fortran compiler changes this reference when it creates the object file.
4. After modifying your C file, compile it into linkable object code with the UNIX command:
cc -c formfile.c
where "formfile.c" is the name of the compiled form source file created by VIFRED.
5. The output of this command is a file with the extension ".o". Link this object file with your program, as shown in the following example:
f77 -o formentry formentry.f \
     formfile.o \
     $II_SYSTEM/ingres/lib/libingres.a\
     -lm \
     -lc   
VMS
To link a precomiled form
1. In VIFRED, select a menu item to compile a form. VIFRED then creates a file in your directory describing the form in the MACRO language. Select a name for the file.
2. Once you have created the MACRO file, assemble it into linkable object code with the VMS command:
macro filename
3. The output of this command is a file with the extension ".obj". Link this object file with your program by listing it in the link command, as shown in the following example:
link formentry,-
 empform.obj,-
 ii_system:[ingres.files]esql.opt/opt  
Windows
To link a precomiled form
1. In VIFRED, select a menu item to compile a form. VIFRED then creates a C language file in your directory describing the form. Select a name for the file.
2. Once you have created the C language file, compile it into linkable object code with the Windows command:
    cl –c –MD filename
3. The output of this command is a file with the extension ".obj". Link this object file with your program by listing it in the link command, as shown in the following example:
link /out:formentry.exe, \
 empform.obj,\
 %II_SYSTEM%\ingres\lib\libingres.lib