Next Previous Contents

4. Building a GEOS sequential application

Before proceeding, please read the compiler, assembler, and linker documentation, and find the appropriate sections about building programs, in general.

GEOS support in cc65 is based on the Convert v2.5 format, well-known in the GEOS world. It means that each file built with the cc65 package has to be deconverted in GEOS, before it can be run. You can read a step-by-step description of that in the GEOS section of the cc65 Compiler Intro.

Each project consists of four parts, two are provided by cc65. Those parts are:

  1. application header
  2. start-up object
  3. application objects
  4. system library
2. and 4. come with cc65; however you have to write the application yourself ;-)

The application header is defined in the HEADER section of the .grc file and is processed into an assembly .s file. You must assemble it, with ca65, into the object .o format.

Assume that there are three input files: "test.c" (a C source), "test.h" (a header file), and "testres.grc" (with menu and header definitions). Note the fact that I don't recommend naming that file "test.grc" because you will have to be very careful with names (grc65 will make "test.s" and "test.h" out of "test.grc" by default; and you don't want that because "test.s" is compiled from "test.c", and "test.h" is something completely different)!

One important thing -- the top of "test.c" looks like:

#include <geos.h>
#include "testres.h"
There are no other includes.

4.1 Building the GEOS application using cl65

This is a simple one step process:

cl65 -t geos-cbm -O -o test.cvt testres.grc test.c
Always place the .grc file as first input file on the command-line in order to make sure that the generated .h file is available when it is needed for inclusion by a .c file.

4.2 Building the GEOS application without cl65

First step -- compiling the resources

grc65 -t geos-cbm testres.grc
will produce two output files: "testres.h" and "testres.s".

Note that "testres.h" is included at the top of "test.c". So, resource compiling must be the first step.

Second step -- assembling the application header

ca65 -t geos-cbm testres.s
And, voilá -- "testres.o" is ready.

Third step -- compiling the code

cc65 -t geos-cbm -O test.c
ca65 -t geos-cbm test.s
That way, you have a "test.o" object file which contains all of the executable code.

Fourth and last step -- linking the application

ld65 -t geos-cbm -o test.cvt testres.o test.o geos-cbm.lib
The last file is the GEOS system library.

The resulting file "test.cvt" is an executable that's contained in the well-known GEOS Convert format. Note that its name (test.cvt) isn't important; the real name, after deconverting, is the DOS name that was given in the header definition.

At each step, a -t geos-cbm was present on the command-line. That switch is required for the correct process of GEOS sequential application building.


Next Previous Contents