1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Building and Running Sample Applications</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos User Guide"
20 HREF="ecos-user-guide.html"><LINK
22 TITLE="Programming With eCos"
23 HREF="user-guide-programming.html"><LINK
25 TITLE="Testing Filters"
26 HREF="testing-filters.html"><LINK
28 TITLE="A Sample Program with Two Threads"
29 HREF="sample-twothreads.html"></HEAD
40 SUMMARY="Header navigation table"
57 HREF="testing-filters.html"
71 HREF="sample-twothreads.html"
84 NAME="BUILDING-AND-RUNNING-SAMPLE-APPLIATIONS">Chapter 13. Building and Running Sample Applications</H1
94 HREF="building-and-running-sample-appliations.html#ECOS-HELLO-WORLD"
102 HREF="sample-twothreads.html"
103 >A Sample Program with Two Threads</A
108 >The example programs in this tutorial are included, along
119 > distribution. The first program you will run is a <SPAN
126 >-style application, then you will run a more complex
127 application that demonstrates the creation of threads and the use
128 of cyg_thread_delay(), and finally you will run
129 one that uses clocks and alarm handlers.</P
134 > depends on an externally
135 defined variable to find the <SPAN
138 > library and header files. This
142 > and must be set to the
143 pathname of the install directory created in <A
144 HREF="using-configtool-windows-linux.html"
145 >the Section called <I
146 >Configuration Tool on Windows and Linux Quick Start</I
153 > may be either be set in the shell
154 environment or may be supplied on the command line. To set it in the
155 shell do the following in a <B
166 CLASS="PROGRAMLISTING"
167 >$ export INSTALL_DIR=BASE_DIR/ecos-work/arm_install</PRE
175 > without any extra parameters
176 to build the examples.</P
178 >Alternatively, if you can do the following:</P
186 CLASS="PROGRAMLISTING"
187 >$ make INSTALL_DIR=BASE_DIR/ecos-work/arm_install</PRE
196 NAME="ECOS-HELLO-WORLD"><SPAN
201 >The following code is found in the file <TT
217 > hello world program listing</H2
225 CLASS="PROGRAMLISTING"
226 >/* this is a simple hello world program */
227 #include <stdio.h>
230 printf("Hello, eCos world!\n");
237 >To compile this or any other program that is not part of the
241 > distribution, you can follow the procedures described below. Type
242 this explicit compilation command (assuming your current working
243 directory is also where you built the <SPAN
254 CLASS="PROGRAMLISTING"
265 >/ecos-work/install/include hello.c -L<TT
270 >/ecos-work/install/lib -Ttarget.ld -nostdlib</PRE
275 >The compilation command above contains some standard GCC
276 options (for example, <TT
279 > enables debugging), as well
280 as some mention of paths
288 >/ecos-work/install/include</TT
292 >cyg/kernel/kapi.h</TT
301 >/ecos-work/install/lib</TT
302 > allows the linker to
308 >The executable program will be called <TT
319 >Some target systems require special options to be passed to
320 gcc to compile correctly for that system. Please examine the Makefile
321 in the examples directory to see if this applies to your target.</P
325 >You can now run the resulting program using GDB in exactly the
326 same the way you ran the test case before. The procedure will be the
327 same, but this time run
340 > on the command line:</P
348 CLASS="PROGRAMLISTING"
359 >For targets other than the synthetic linux target, you should
360 now run the usual GDB commands described earlier. Once this is done,
361 typing the command "continue" at the (gdb) prompt ("run" for
362 simulators) will allow the program to execute and print the string
363 "Hello, eCos world!" on your screen.</P
365 >On the synthetic linux target, you may use the "run" command
366 immediately - you do not need to connect to the target, nor use the
376 SUMMARY="Footer navigation table"
387 HREF="testing-filters.html"
396 HREF="ecos-user-guide.html"
405 HREF="sample-twothreads.html"
421 HREF="user-guide-programming.html"
429 >A Sample Program with Two Threads</TD