How Embedded SQL Programs are Linked
Embedded SQL programs require procedures from an Ingres library or libraries depending on your operating system as described below.
Linux:
The Ingres library "libingres.a" must be included in your compile (f77) or link (ld) command after all user modules. The following example demonstrates how to compile and link an Embedded SQL program called "dbentry" that has passed through the preprocessor:
f77 -o dbentry dbentry.f \
$II_SYSTEM/ingres/lib/libingres.a\
-lm\
-lc
Note that you must include the math library (the "m" argument to the -l flag).
Ingres shared libraries are available on some Linux platforms. To link with these shared libraries replace "libingres.a" in your link command with:
-L $II_SYSTEM/ingres/lib -linterp.1 -lframe.1 -lq.1 \
-lcompat.1
To verify if your release supports shared libraries check for the existence of any of these four shared libraries in the $II_SYSTEM/ingres/lib directory. For example:
ls -l $II_SYSTEM/ingres/lib/libq.1.*
Windows:
The Ingres library libingres.lib must be included in your compile (df) or link (link) command after all user modules. The following example demonstrates how to compile and link an Embedded SQL program called "dbentry" that has passed through the preprocessor:
df /name:as_is /iface:nomixed_str_len_arg /iface:cref dbentry.for \
%II_SYSTEM%\ingres\lib\libingres.lib \
/link /nodefaultlib
Link Precompiled Forms
The
Forms-based Application Development Tools User Guide and the
Fortran Variables and Data Types discuss how to declare a precompiled form to the FRS. To use such a form in your program, you must also follow the steps described below, depending on your operating system.
Linux:
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 Linux 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
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
Last modified date: 08/14/2024