Cleared the top bytes for use in arrays.
[fw/sdcc] / doc / sdccman.html / node13.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>2.3 Testing out the SDCC Compiler</TITLE>
11 <META NAME="description" CONTENT="2.3 Testing out the SDCC Compiler">
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="node14.html">
23 <LINK REL="previous" HREF="node12.html">
24 <LINK REL="up" HREF="node10.html">
25 <LINK REL="next" HREF="node14.html">
26 </HEAD>
27
28 <BODY >
29 <!--Navigation Panel-->
30 <A NAME="tex2html398"
31  HREF="node14.html">
32 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
33 <A NAME="tex2html392"
34  HREF="node10.html">
35 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
36 <A NAME="tex2html386"
37  HREF="node12.html">
38 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
39 <A NAME="tex2html394"
40  HREF="node1.html">
41 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
42 <A NAME="tex2html396"
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="tex2html399"
47  HREF="node14.html">2.4 Install Trouble-shooting</A>
48 <B> Up:</B> <A NAME="tex2html393"
49  HREF="node10.html">2. Installation</A>
50 <B> Previous:</B> <A NAME="tex2html387"
51  HREF="node12.html">2.2 Windows Installation</A>
52  &nbsp <B>  <A NAME="tex2html395"
53  HREF="node1.html">Contents</A></B> 
54  &nbsp <B>  <A NAME="tex2html397"
55  HREF="node61.html">Index</A></B> 
56 <BR>
57 <BR>
58 <!--End of Navigation Panel-->
59
60 <H2><A NAME="SECTION00033000000000000000">
61 2.3 Testing out the SDCC Compiler</A>
62 </H2>
63
64 <P>
65 The first thing you should do after installing your SDCC compiler
66 is to see if it runs. Type <I><B>&#34;sdcc -version&#34;</B></I>
67 at the prompt, and the program should run and tell you the version.
68 If it doesn't run, or gives a message about not finding sdcc program,
69 then you need to check over your installation. Make sure that the
70 sdcc bin directory is in your executable search path defined by the
71 PATH environment setting (see the Trouble-shooting section for suggestions).
72 Make sure that the sdcc program is in the bin folder, if not perhaps
73 something did not install correctly.
74 <BR>
75
76 <BR>
77 SDCC binaries are commonly installed in a directory arrangement like
78 this:
79 <BR>
80
81 <BR>
82 <TABLE CELLPADDING=3 BORDER="1">
83 <TR><TD ALIGN="LEFT">/usr/local/bin</TD>
84 <TD ALIGN="LEFT">Holds executables(sdcc, s51, aslink, ...)</TD>
85 </TR>
86 <TR><TD ALIGN="LEFT">/usr/local/share/sdcc/lib</TD>
87 <TD ALIGN="LEFT">Holds common C libraries</TD>
88 </TR>
89 <TR><TD ALIGN="LEFT">/usr/local/share/sdcc/include</TD>
90 <TD ALIGN="LEFT">Holds common C header files</TD>
91 </TR>
92 </TABLE>
93 <BR>
94
95 <BR>
96 Make sure the compiler works on a very simple example. Type in the
97 following test.c program using your favorite editor:
98 <BR>
99 <BR>
100 <TT>int test(int t) {</TT>&nbsp;
101 <BR>
102 <TT>&nbsp;&nbsp;&nbsp;&nbsp;return t+3;</TT>&nbsp;
103 <BR>
104 <TT>}</TT>
105 <BR>
106 <BR>
107 Compile this using the following command: <I><B>&#34;sdcc
108 -c test.c&#34;.</B></I> If all goes well, the compiler will generate
109 a test.asm and test.rel file. Congratulations, you've just compiled
110 your first program with SDCC. We used the -c option to tell SDCC not
111 to link the generated code, just to keep things simple for this step.
112 <BR>
113
114 <BR>
115 The next step is to try it with the linker. Type in <I><B>&#34;sdcc
116 test.c</B></I>&#34;. If all goes well the compiler will link with the
117 libraries and produce a test.ihx output file. If this step fails (no
118 test.ihx, and the linker generates warnings), then the problem is
119 most likely that sdcc cannot find the /usr/local/share/sdcc/lib directory
120 (see the Install trouble-shooting section for suggestions).
121 <BR>
122
123 <BR>
124 The final test is to ensure sdcc can use the standard header files
125 and libraries. Edit test.c and change it to the following:
126 <BR>
127
128 <BR>
129 #include &lt;string.h&gt;
130 <BR>
131 main() {
132 <BR>
133 <TT>char str1[10];</TT>&nbsp;
134 <BR>
135 <TT>&nbsp;&nbsp;&nbsp;&nbsp;strcpy(str1, &#34;testing&#34;);</TT>&nbsp;
136 <BR>
137 <TT>}</TT>&nbsp;
138 <BR>&nbsp;
139 <BR>
140 Compile this by typing <I><B>&#34;sdcc test.c&#34;</B></I>.
141 This should generate a test.ihx output file, and it should give no
142 warnings such as not finding the string.h file. If it cannot find
143 the string.h file, then the problem is that sdcc cannot find the /usr/local/share/sdcc/include
144 directory (see the Install trouble-shooting section for suggestions).
145
146 <P>
147 <HR>
148 <!--Navigation Panel-->
149 <A NAME="tex2html398"
150  HREF="node14.html">
151 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
152 <A NAME="tex2html392"
153  HREF="node10.html">
154 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
155 <A NAME="tex2html386"
156  HREF="node12.html">
157 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
158 <A NAME="tex2html394"
159  HREF="node1.html">
160 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
161 <A NAME="tex2html396"
162  HREF="node61.html">
163 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
164 <BR>
165 <B> Next:</B> <A NAME="tex2html399"
166  HREF="node14.html">2.4 Install Trouble-shooting</A>
167 <B> Up:</B> <A NAME="tex2html393"
168  HREF="node10.html">2. Installation</A>
169 <B> Previous:</B> <A NAME="tex2html387"
170  HREF="node12.html">2.2 Windows Installation</A>
171  &nbsp <B>  <A NAME="tex2html395"
172  HREF="node1.html">Contents</A></B> 
173  &nbsp <B>  <A NAME="tex2html397"
174  HREF="node61.html">Index</A></B> 
175 <!--End of Navigation Panel-->
176 <ADDRESS>
177 <I>Johan Knol</I>
178 <BR><I>2001-07-13</I>
179 </ADDRESS>
180 </BODY>
181 </HTML>