Reshaped doc's
[fw/sdcc] / doc / sdccman.html / node20.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
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 -->
8 <HTML>
9 <HEAD>
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">
15
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">
19
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
21
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">
26 </HEAD>
27
28 <BODY >
29 <!--Navigation Panel-->
30 <A NAME="tex2html540"
31  HREF="node21.html">
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
33 <A NAME="tex2html534"
34  HREF="node19.html">
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
36 <A NAME="tex2html528"
37  HREF="node19.html">
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
39 <A NAME="tex2html536"
40  HREF="node1.html">
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
42 <A NAME="tex2html538"
43  HREF="node61.html">
44 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
45 <BR>
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  &nbsp <B>  <A NAME="tex2html537"
53  HREF="node1.html">Contents</A></B> 
54  &nbsp <B>  <A NAME="tex2html539"
55  HREF="node61.html">Index</A></B> 
56 <BR>
57 <BR>
58 <!--End of Navigation Panel-->
59 <!--Table of Child-Links-->
60 <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
61
62 <UL>
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>
69 </UL>
70 <!--End of Table of Child-Links-->
71 <HR>
72
73 <H2><A NAME="SECTION00041000000000000000">
74 3.1 Compiling</A>
75 </H2>
76
77 <P>
78
79 <H3><A NAME="SECTION00041100000000000000">
80 3.1.1 Single Source File Projects</A>
81 </H3>
82
83 <P>
84 For single source file 8051 projects the process is very simple. Compile
85 your programs with the following command <I><B>&#34;sdcc
86 sourcefile.c&#34;.</B></I> This will compile, assemble and link your
87 source file. Output files are as follows
88 <BR>
89
90 <BR>
91 sourcefile.asm - Assembler source file created by the compiler
92 <BR>
93 sourcefile.lst - Assembler listing file created by the Assembler
94 <BR>
95 sourcefile.rst - Assembler listing file updated with linkedit information,
96 created by linkage editor
97 <BR>
98 sourcefile.sym - symbol listing for the sourcefile, created by the
99 assembler
100 <BR>
101 sourcefile.rel - Object file created by the assembler, input to Linkage
102 editor
103 <BR>
104 sourcefile.map - The memory map for the load module, created by the
105 Linker
106 <BR>
107 sourcefile.ihx - The load module in Intel hex format (you can select
108 the Motorola S19 format with -out-fmt-s19)
109 <BR>
110 sourcefile.cdb - An optional file (with -debug) containing debug
111 information
112 <BR>
113
114 <P>
115
116 <H3><A NAME="SECTION00041200000000000000">
117 3.1.2 Projects with Multiple Source Files</A>
118 </H3>
119
120 <P>
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:
123 <BR>
124
125 <BR>
126 foo1.c (contains some functions)
127 <BR>
128 foo2.c (contains some more functions)
129 <BR>
130 foomain.c (contains more functions and the function main)
131 <BR>
132
133 <BR>
134 The first two files will need to be compiled separately with the commands:
135
136 <BR>
137
138 <BR>
139 <I><B>sdcc&nbsp;-c&nbsp;foo1.c</B></I>
140 <BR>
141 <I><B>sdcc&nbsp;-c&nbsp;foo2.c</B></I>
142 <BR>
143
144 <BR>
145 Then compile the source file containing the <I>main()</I> function
146 and link the files together with the following command: 
147 <BR>
148
149 <BR>
150 <I><B>sdcc&nbsp;foomain.c&nbsp;foo1.rel&nbsp;foo2.rel</B></I>
151 <BR>
152
153 <BR>
154 Alternatively, <I>foomain.c</I> can be separately compiled as well:
155 <BR>
156 <BR>
157 <I><B>sdcc&nbsp;-c&nbsp;foomain.c</B></I>
158 <BR>
159 <I><B>sdcc foomain.rel foo1.rel foo2.rel</B></I>
160 <BR>
161 <BR>
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.
165
166 <P>
167
168 <H3><A NAME="SECTION00041300000000000000">
169 3.1.3 Projects with Additional Libraries</A>
170 </H3>
171
172 <P>
173 Some reusable routines may be compiled into a library, see the documentation
174 for the assembler and linkage editor (which are in &lt;installdir&gt;/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 &lt;library-path&gt; 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
181 project):
182 <BR>
183
184 <BR>
185 <I><B>sdcc foomain.c foolib.lib -L mylib</B></I>
186 <BR>
187 <BR>
188 Note here that <I>mylib</I> must be an absolute path name.
189 <BR>
190
191 <BR>
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 &lt;installdir&gt;/share/lib/small.
196
197 <P>
198 <HR>
199 <!--Navigation Panel-->
200 <A NAME="tex2html540"
201  HREF="node21.html">
202 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
203 <A NAME="tex2html534"
204  HREF="node19.html">
205 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
206 <A NAME="tex2html528"
207  HREF="node19.html">
208 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
209 <A NAME="tex2html536"
210  HREF="node1.html">
211 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
212 <A NAME="tex2html538"
213  HREF="node61.html">
214 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
215 <BR>
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  &nbsp <B>  <A NAME="tex2html537"
223  HREF="node1.html">Contents</A></B> 
224  &nbsp <B>  <A NAME="tex2html539"
225  HREF="node61.html">Index</A></B> 
226 <!--End of Navigation Panel-->
227 <ADDRESS>
228 <I>Johan Knol</I>
229 <BR><I>2001-07-13</I>
230 </ADDRESS>
231 </BODY>
232 </HTML>