Viitor_cc65/usr/share/doc/cc65/webdoc/grc-4.html
kueller 223cc6685e Neue Version V963
git-svn-id: svn://svn.compuextreme.de/Viitor/V963/Viitor_cc65@5933 504e572c-2e33-0410-9681-be2bf7408885
2011-01-03 10:48:06 +00:00

124 lines
4.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20">
<TITLE>grc -- GEOS Resource Compiler: Building a GEOS sequential application</TITLE>
<LINK HREF="grc-5.html" REL=next>
<LINK HREF="grc-3.html" REL=previous>
<LINK HREF="grc.html#toc4" REL=contents>
</HEAD>
<BODY>
<A HREF="grc-5.html">Next</A>
<A HREF="grc-3.html">Previous</A>
<A HREF="grc.html#toc4">Contents</A>
<HR>
<H2><A NAME="building-seq"></A> <A NAME="s4">4.</A> <A HREF="grc.html#toc4">Building a GEOS sequential application</A></H2>
<P>Before proceeding, please read the
<A HREF="cc65.html">compiler</A>,
<A HREF="ca65.html">assembler</A>, and
<A HREF="ld65.html">linker</A>
documentation, and find the appropriate sections about building programs, in
general.</P>
<P>GEOS support in cc65 is based on the <EM>Convert v2.5</EM> 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
<A HREF="intro.html">cc65 Compiler Intro</A>.</P>
<P>Each project consists of four parts, two are provided by cc65. Those parts
are:
<OL>
<LI>application header</LI>
<LI>start-up object</LI>
<LI>application objects</LI>
<LI>system library</LI>
</OL>
<B>2.</B> and <B>4.</B> are with cc65; you have to write the application,
yourself. ;-)</P>
<P>The application header is defined in the <CODE>HEADER</CODE> section of the <CODE>.grc</CODE>
file, and processed into an assembly <CODE>.s</CODE> file. You must assemble it, with
<B>ca65</B>, into the object <CODE>.o</CODE> format.</P>
<H2><A NAME="ss4.1">4.1</A> <A HREF="grc.html#toc4.1">Building a GEOS application without cl65</A>
</H2>
<P>Assume that there are three input files: &quot;<CODE>test.c</CODE>&quot; (a C
source), &quot;<CODE>test.h</CODE>&quot; (a header file), and
&quot;<CODE>resource.grc</CODE>&quot; (with menu and header definitions). Note the
fact that I <EM>don't recommend</EM> naming that file &quot;<CODE>test.grc</CODE>&quot;,
because you will have to be very careful with names (<B>grc</B> will make
&quot;<CODE>test.s</CODE>&quot; and &quot;<CODE>test.h</CODE>&quot; out of
&quot;<CODE>test.grc</CODE>&quot;, by default; and, you don't want that because
&quot;<CODE>test.s</CODE>&quot; is compiled from &quot;<CODE>test.c</CODE>&quot;, and
&quot;<CODE>test.h</CODE>&quot; is something completely different)!</P>
<P><B>One important thing</B> -- the top of &quot;<CODE>test.c</CODE>&quot; looks like:
<BLOCKQUOTE><CODE>
<PRE>
#include &lt;geos.h>
#include "resource.h"
</PRE>
</CODE></BLOCKQUOTE>
There are no other includes.</P>
<H3>First step -- compiling the resources</H3>
<P>
<PRE>
$ grc resource.grc
</PRE>
will produce two output files: &quot;<CODE>resource.h</CODE>&quot; and
&quot;<CODE>resource.s</CODE>&quot;.</P>
<P>Note that &quot;<CODE>resource.h</CODE>&quot; is included at the top of
&quot;<CODE>test.c</CODE>&quot;. So, resource compiling <EM>must be</EM> the first step.</P>
<H3>Second step -- assembling the application header</H3>
<P>
<PRE>
$ ca65 -t geos resource.s
</PRE>
And, voil&aacute; -- &quot;<CODE>resource.o</CODE>&quot; is ready.</P>
<H3>Third step -- compiling the code</H3>
<P>
<PRE>
$ cc65 -t geos -O test.c
$ ca65 -t geos test.s
</PRE>
That way, you have a &quot;<CODE>test.o</CODE>&quot; object file which
contains all of the executable code.</P>
<H3>Fourth and last step -- linking it together</H3>
<P>
<PRE>
$ ld65 -t geos -o test.cvt resource.o geos.o test.o geos.lib
</PRE>
&quot;<CODE>resource.o</CODE>&quot; comes first because it contains the
header. The next one is &quot;<CODE>geos.o</CODE>&quot;, a required starter-code
file; then, the actual application code in &quot;<CODE>test.o</CODE>&quot;, and the
last is the GEOS system library.</P>
<P>The resulting file &quot;<CODE>test.cvt</CODE>&quot; is an executable that's
contained in the well-known GEOS <EM>Convert</EM> format. Note that it's name
(<CODE>test</CODE>) isn't important; the real name, after deconverting, is the DOS name
that was given in the header definition.</P>
<P>At each step, a <CODE>-t geos</CODE> was present on the command-line. That switch is
required for the correct process of GEOS sequential app. building.</P>
<HR>
<A HREF="grc-5.html">Next</A>
<A HREF="grc-3.html">Previous</A>
<A HREF="grc.html#toc4">Contents</A>
</BODY>
</HTML>