<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2008 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>3.1.3 Projects with Multiple Source Files</TITLE> <META NAME="description" CONTENT="3.1.3 Projects with Multiple Source Files"> <META NAME="keywords" CONTENT="sdccman"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="sdccman.css"> <LINK REL="next" HREF="node42.html"> <LINK REL="previous" HREF="node40.html"> <LINK REL="up" HREF="node38.html"> <LINK REL="next" HREF="node42.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html1283" HREF="node42.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1277" HREF="node38.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1271" HREF="node40.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1279" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1281" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1284" HREF="node42.html">3.1.4 Projects with Additional</A> <B> Up:</B> <A NAME="tex2html1278" HREF="node38.html">3.1 Compiling</A> <B> Previous:</B> <A NAME="tex2html1272" HREF="node40.html">3.1.2 Postprocessing the Intel</A> <B> <A NAME="tex2html1280" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html1282" HREF="node191.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <H2><A NAME="SECTION00413000000000000000"> 3.1.3 Projects with Multiple Source Files</A> </H2> <P> SDCC can compile only ONE file at a time. Let us for example assume that you have a project containing the following files: <BR> <BR> foo1.c (contains some functions) <BR> foo2.c (contains some more functions) <BR> foomain.c (contains more functions and the function main) <BR> <BR> The first two files will need to be compiled separately with the commands:<FONT SIZE="-1"> </FONT> <BR> <BR><I><B>sdcc -c foo1.c</B></I> <BR><I><B>sdcc -c foo2.c</B></I> <BR> <BR> Then compile the source file containing the <I>main()</I> function and link<A NAME="750"></A> the files together with the following command: <BR> <BR><I><B>sdcc foomain.c foo1.rel foo2.rel</B></I><A NAME="752"></A> <BR> <BR> Alternatively, <I>foomain.c</I> can be separately compiled as well: <BR> <BR><I><B>sdcc -c foomain.c</B></I> <BR><I><B>sdcc foomain.rel foo1.rel foo2.rel</B></I> <BR> <BR> The file containing the <I>main()</I> function <SMALL>MUST</SMALL> be the <SMALL>FIRST</SMALL> file specified in the command line, since the linkage editor processes file in the order they are presented to it. The linker is invoked from SDCC using a script file with extension .lnk<A NAME="762"></A>. You can view this file to troubleshoot linking problems such as those arising from missing libraries. <P> <HR> <!--Navigation Panel--> <A NAME="tex2html1283" HREF="node42.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1277" HREF="node38.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1271" HREF="node40.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1279" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1281" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1284" HREF="node42.html">3.1.4 Projects with Additional</A> <B> Up:</B> <A NAME="tex2html1278" HREF="node38.html">3.1 Compiling</A> <B> Previous:</B> <A NAME="tex2html1272" HREF="node40.html">3.1.2 Postprocessing the Intel</A> <B> <A NAME="tex2html1280" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html1282" HREF="node191.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> 2011-03-20 </ADDRESS> </BODY> </HTML>