[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.1 Making the Extension

As described above, a Cogsys extension is just an object file that has been run through the Cogsys Extension Routine Generator COGXRG program. This section tells you how to turn a C source file into a CXR file. If you are interested only in making modifications to an existing extension, copy that extension's source file to a new name, make the modifications, and follow these instructions. To write a new extension from scratch, see Writing a New Extension.

It is important to note that object files, while conforming to the same general structure on a particular operating system, differ significantly for each compiler. The COGXRG program is currently designed to work only with object files created by the Borland Turbo C/C++ 3.00 Compiler. (In principle, COGXRG should be easily modified to allow objects of other C compilers, or even of other language compilers, like Fortran. See section New Directions.

So given the extension source, all that is needed is to compile it with the appropriate options, and run COGXRG on it. To build a new extension from it source, say `MYEXT.C', you would do something like this:

 
C:\> tcc -ml -c myext.c

C:\> cogxrg myext.obj

The `-ml' option tells the Turbo C compiler to use its large memory model, which is critical to generate an object that uses memory the same way the main program does. The `-c' option tells the compiler to just generate the object file (and not attempt to link it). Of course, if `myext.c' needed additional command line arguments (most commonly, the `-I' directive to specify locations of header files) they would also be added to the compile command.

The process can be made even simpler using makefiles. make is a standard programming tool (available on all Unix systems, and included with Borland Turbo C/C++ 3.00 for MS-DOS) to help the automation of compiling programs. It is a sophisticated program and a discussion of its features are beyond the scope of this book (Make, by O'Reilly and Associates, is an excellent reference). Here we simply note that the following lines saved in a file called `Makefile' can be effectively used in CXR development:

 
# Makefile for Cogsys 3.0 Extensions

#
# Compiler and flags
CC = tcc
CFLAGS = -ml 

#
# Cogsys external routine generator
COGXRG = cogxrg

#
# CXR Entries
#

all: myext.cxr

myext.cxr: myext.obj cogxrg.exe
        $(COGXRG) myext.obj > myext.out

myext.obj: myext.c
        $(CC) $(CFLAGS) -c myext.c

#
# Clean
#

clean:
        del *.obj
        del *.cxr
        del *.out

Now, simply typing make will rebuild the object and CXR files if either or both are out of date. Typing make clean will clear all generated files (but leave the source file `myext.c' untouched). Once the `MYEXT.CXR' file is built cleanly, it can be copied to the client machines and used in new testlists with the Load Extension Routine (%X) command.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Usman Muzaffar on June, 28 2000 using texi2html