| <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. Using Sourcery G++ from the Command Line</title><link rel="stylesheet" href="cs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><meta name="description" content=" This chapter demonstrates the use of Sourcery G++ Lite from the command line."><link rel="home" href="index.html" title="Sourcery G++ Lite"><link rel="up" href="index.html" title="Sourcery G++ Lite"><link rel="prev" href="portable-objects.html" title="3.12. Object File Portability"><link rel="next" href="ch04s02.html" title="4.2. Running Applications on the Target System"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. Using Sourcery G++ from the Command Line</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="portable-objects.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch04s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="chap-building"></a>Chapter 4. Using Sourcery G++ from the Command Line</h2></div><div><div class="abstract"><p class="title"><b></b></p><p> |
| This chapter demonstrates the use of Sourcery G++ Lite from the command line. |
| |
| </p></div></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="chap-building.html#sec-factorial-build">4.1. Building an Application</a></span></dt><dt><span class="section"><a href="ch04s02.html">4.2. Running Applications on the Target System</a></span></dt><dt><span class="section"><a href="sec-remote-debugging.html">4.3. Running Applications from GDB</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-factorial-build"></a>4.1. Building an Application</h2></div></div></div><p> |
| This chapter explains how to build an application with Sourcery G++ Lite using |
| the command line. As elsewhere in this manual, this section assumes |
| that your target system is arm-none-linux-gnueabi, as indicated by the |
| <code class="command">arm-none-linux-gnueabi</code> command prefix. |
| </p><p> |
| Using an editor (such as <code class="command">notepad</code> on Microsoft |
| Windows or <code class="command">vi</code> on UNIX-like systems), create a |
| file named <code class="filename">main.c</code> containing the following |
| simple factorial program: |
| </p><pre class="programlisting">#include <stdio.h> |
| |
| int factorial(int n) { |
| if (n == 0) |
| return 1; |
| return n * factorial (n - 1); |
| } |
| |
| int main () { |
| int i; |
| int n; |
| for (i = 0; i < 10; ++i) { |
| n = factorial (i); |
| printf ("factorial(%d) = %d\n", i, n); |
| } |
| return 0; |
| } |
| </pre><p> |
| </p><p> |
| Compile and link this program using the command: |
| </p><pre class="screen">> arm-none-linux-gnueabi-gcc -o factorial main.c</pre><p> |
| </p><p> |
| There should be no output from the compiler. (If you are building a |
| C++ application, instead of a C application, replace |
| <code class="command">arm-none-linux-gnueabi-gcc</code> with |
| <code class="command">arm-none-linux-gnueabi-g++</code>.) |
| </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="portable-objects.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch04s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.12. Object File Portability </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.2. Running Applications on the Target System</td></tr></table></div></body></html> |