1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
3 <!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
4 original version by: Nikos Drakos, CBLU, University of Leeds
5 * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
6 * with significant contributions from:
7 Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
10 <TITLE>3.1 Compiling</TITLE>
11 <META NAME="description" CONTENT="3.1 Compiling">
12 <META NAME="keywords" CONTENT="sdccman">
13 <META NAME="resource-type" CONTENT="document">
14 <META NAME="distribution" CONTENT="global">
16 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
17 <META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
18 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
22 <LINK REL="next" HREF="node21.html">
23 <LINK REL="previous" HREF="node19.html">
24 <LINK REL="up" HREF="node19.html">
25 <LINK REL="next" HREF="node21.html">
29 <!--Navigation Panel-->
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
46 <B> Next:</B> <A NAME="tex2html541"
47 HREF="node21.html">3.2 Command Line Options</A>
48 <B> Up:</B> <A NAME="tex2html535"
49 HREF="node19.html">3. Using SDCC</A>
50 <B> Previous:</B> <A NAME="tex2html529"
51 HREF="node19.html">3. Using SDCC</A>
52   <B> <A NAME="tex2html537"
53 HREF="node1.html">Contents</A></B>
54   <B> <A NAME="tex2html539"
55 HREF="node61.html">Index</A></B>
58 <!--End of Navigation Panel-->
59 <!--Table of Child-Links-->
60 <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
63 <LI><A NAME="tex2html542"
64 HREF="node20.html#SECTION00041100000000000000">3.1.1 Single Source File Projects</A>
65 <LI><A NAME="tex2html543"
66 HREF="node20.html#SECTION00041200000000000000">3.1.2 Projects with Multiple Source Files</A>
67 <LI><A NAME="tex2html544"
68 HREF="node20.html#SECTION00041300000000000000">3.1.3 Projects with Additional Libraries</A>
70 <!--End of Table of Child-Links-->
73 <H2><A NAME="SECTION00041000000000000000">
79 <H3><A NAME="SECTION00041100000000000000">
80 3.1.1 Single Source File Projects</A>
84 For single source file 8051 projects the process is very simple. Compile
85 your programs with the following command <I><B>"sdcc
86 sourcefile.c".</B></I> This will compile, assemble and link your
87 source file. Output files are as follows
91 sourcefile.asm - Assembler source file created by the compiler
93 sourcefile.lst - Assembler listing file created by the Assembler
95 sourcefile.rst - Assembler listing file updated with linkedit information,
96 created by linkage editor
98 sourcefile.sym - symbol listing for the sourcefile, created by the
101 sourcefile.rel - Object file created by the assembler, input to Linkage
104 sourcefile.map - The memory map for the load module, created by the
107 sourcefile.ihx - The load module in Intel hex format (you can select
108 the Motorola S19 format with -out-fmt-s19)
110 sourcefile.cdb - An optional file (with -debug) containing debug
116 <H3><A NAME="SECTION00041200000000000000">
117 3.1.2 Projects with Multiple Source Files</A>
121 SDCC can compile only ONE file at a time. Let us for example assume
122 that you have a project containing the following files:
126 foo1.c (contains some functions)
128 foo2.c (contains some more functions)
130 foomain.c (contains more functions and the function main)
134 The first two files will need to be compiled separately with the commands:
139 <I><B>sdcc -c foo1.c</B></I>
141 <I><B>sdcc -c foo2.c</B></I>
145 Then compile the source file containing the <I>main()</I> function
146 and link the files together with the following command:
150 <I><B>sdcc foomain.c foo1.rel foo2.rel</B></I>
154 Alternatively, <I>foomain.c</I> can be separately compiled as well:
157 <I><B>sdcc -c foomain.c</B></I>
159 <I><B>sdcc foomain.rel foo1.rel foo2.rel</B></I>
162 The file containing the <I>main()</I> function <SMALL>MUST</SMALL>
163 be the <SMALL>FIRST</SMALL> file specified in the command line, since the
164 linkage editor processes file in the order they are presented to it.
168 <H3><A NAME="SECTION00041300000000000000">
169 3.1.3 Projects with Additional Libraries</A>
173 Some reusable routines may be compiled into a library, see the documentation
174 for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
175 for how to create a <I>.lib</I> library file. Libraries created in
176 this manner can be included in the command line. Make sure you include
177 the -L <library-path> option to tell the linker where to look for
178 these files if they are not in the current directory. Here is an example,
179 assuming you have the source file <I>foomain.c</I> and a library <I>foolib.lib</I>
180 in the directory <I>mylib</I> (if that is not the same as your current
185 <I><B>sdcc foomain.c foolib.lib -L mylib</B></I>
188 Note here that <I>mylib</I> must be an absolute path name.
192 The most efficient way to use libraries is to keep seperate modules
193 in seperate source files. The lib file now should name all the modules.rel
194 files. For an example see the standard library file <I>libsdcc.lib</I>
195 in the directory <installdir>/share/lib/small.
199 <!--Navigation Panel-->
200 <A NAME="tex2html540"
202 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
203 <A NAME="tex2html534"
205 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
206 <A NAME="tex2html528"
208 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
209 <A NAME="tex2html536"
211 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
212 <A NAME="tex2html538"
214 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
216 <B> Next:</B> <A NAME="tex2html541"
217 HREF="node21.html">3.2 Command Line Options</A>
218 <B> Up:</B> <A NAME="tex2html535"
219 HREF="node19.html">3. Using SDCC</A>
220 <B> Previous:</B> <A NAME="tex2html529"
221 HREF="node19.html">3. Using SDCC</A>
222   <B> <A NAME="tex2html537"
223 HREF="node1.html">Contents</A></B>
224   <B> <A NAME="tex2html539"
225 HREF="node61.html">Index</A></B>
226 <!--End of Navigation Panel-->
229 <BR><I>2001-07-13</I>