Was this helpful?
How Embedded SQL Programs are Linked--VMS
Embedded SQL programs require procedures from several VMS shared libraries in order to run properly. Once you have preprocessed and compiled an embedded SQL program, you can link it. Assuming the object file for your program is called dbentry, use the following link command:
$link dbentry.obj,-
 ii_system:[ingres.files]esql.opt/opt,-
 sys$library:vaxcrtl.olb/library
The last line in the link command shown above serves to link the C runtime library for certain basic C functions, such as printf. You need to include this line only if you use those functions in your program.
Link Precompiled Forms
The technique of declaring a precompiled form to the FRS is discussed in the Forms‑based Application Development Tools User Guide. To use such a form in your program, you must also follow the steps described here.
To link a precompiled 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 VAX11 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,-
 sys$library:vaxcrtl.olb/library
How Embedded SQL Programs are Linked Without Shared Libraries
While the use of shared libraries in linking embedded SQL programs is recommended for optimal performance and ease of maintenance, non-shared versions of the libraries have been included in case you require them. Non-shared libraries required by embedded SQL are listed in the esql.noshare options file. The options file must be included in your link command after all user modules. Libraries must be specified in the order given in the options file.
The following example demonstrates the link command of an embedded SQL program called dbentry that has been preprocessed and compiled:
$link dbentry,-
 ii_system:[ingres.files]esql.noshare/opt
User-Written Embedded SQL Routines in Shareable Images
When you plan to place your code in a shareable image, note the following about the psect attributes of your global or external variables:
As a default, some compilers mark global variables as shared (SHR: every user who runs a program linked to the shareable image sees the same variable) and others mark them as not shared (NOSHR: every user who runs a program linked to the shareable image gets a private copy of the variable).
Some compilers support modifiers you can place in your source code variable declaration statements to explicitly state which attributes to assign a variable.
The attributes that a compiler assigns to a variable can be overridden at link time with the psect_attr link option. This option overrides attributes of all variables in the psect.
Consult your compiler reference manual for further details.
Last modified date: 01/30/2023