| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (6 out of 10)

Using the Overlay Utility through the Makefile

The next step to creating a foreign image is to use the Overlay utility and to compile and link the appropriate files.

Gensym provides the Overlay utility specifically for use with foreign functions. The utility takes the template file as an input file and outputs a C source file, called an overlay file, which marshals the arguments and return types for use by G2. The Overlay utility resides in the \ext subdirectory of the G2 product directory.

Gensym also provides the foreign.h and the icp.h header files, and the libforgn.lib library, which are all used by the makefile as part of compiling and linking the files.

In conjunction with using the Overlay utility, Gensym also provides a platform-specific makefile, also located in the ext subdirectory. The makefile calls the Overlay utility, and compiles and links the files you need to create the foreign image.

Completing the Makefile Global Variables

The makefile that Gensym provides is an example. As such, you need to complete several global variables before using the makefile:

Variable name: For the:
C_DIR
Location of the C source file if other than the makefile directory.
OBJ_DIR
Location of the obj files if other than the makefile directory.
EXE_DIR
Directory in which to place the resulting executable.
TEMPLATE_DIR
Location of the template file you created if other than the makefile directory. By default, the makefile assumes that the template file resides in the same directory as the C source file, so you do not have to complete this value.
OVERLAY_DIR
The location of the overlay executable.
H_DIR
The location of the required header files.
CC_FLAGS

LIB_DIR
The location of the required libraries.

If you are building the example foreign image with the files Gensym provides, edit the makefile as the preceding table describes.

If you are building a foreign image with your own C source and template files, edit the makefile as the preceding table describes and include the appropriate source and template files.


Note: The name that you provide for the executable foreign image must have a suffix of .fgn so that G2 can locate it in your directory. In the sample makefile, the file name is fgntest.fgn.

Running the Makefile

Run the Gensym makefile as you would any other makefile on your platform.

Using the Overlay Utility on OpenVMS

To use the makefile to run the Overlay utility on OpenVMS, you must first define an overlay symbol as follows:

The first command defines the symbol that OpenVMS requires to pass command line arguments to the Overlay utility, where my$dev:[my.directory] is the complete pathname for the Overlay utility. The second command runs the Overlay utility with the command line arguments specifying the template (input) and overlay (output) files.

OpenVMS and VAX/VMS Options File

OpenVMS and VAX/VMS link commands often include a linker options file. As an example of such a file, this three-line text file consists of the following statements:

where foreign-code-file is the name of the object file (fgntest.obj in the example), generated-overlay-file is the name of the overlay file (foverlay.obj in this example, and my$dev:[library.directory] libforgn.olb is the full pathname for the location of the Gensym-provided libforgn.olb library. Following is an example of such a file:


The linker options file can contain additional lines such as additional source files or libraries, in case you built your existing C or C++ functions with a more complicated arrangement. Lines beginning with an exclamation mark (!) are comments. For more information on VMS options files, see your VMS documentation on the linker.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (6 out of 10)

Copyright © 1997 Gensym Corporation, Inc.