• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/getting-started/
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter�4.�Using Sourcery CodeBench from the Command Line</title><link rel="stylesheet" type="text/css" href="cs.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.0"><meta name="description" content=" This chapter demonstrates the use of Sourcery CodeBench Lite from the command line."><link rel="home" href="index.html" title="Sourcery CodeBench Lite"><link rel="up" href="index.html" title="Sourcery CodeBench Lite"><link rel="prev" href="portable-objects.html" title="3.8.�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 CodeBench 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"><div class="titlepage"><div><div><h1 class="title"><a name="chap-building"></a>Chapter�4.�Using Sourcery CodeBench from the Command Line</h1></div><div><div class="abstract"><p class="title"><b></b></p><p>
2    This chapter demonstrates the use of Sourcery CodeBench Lite from the command line.
3    
4   </p></div></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><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><dt><span class="section"><a href="sec-cs.html">4.4. Using the Compiler Cache</a></span></dt></dl></div><div class="section"><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>
5   This chapter explains how to build an application with Sourcery CodeBench Lite using
6   the command line.  As elsewhere in this manual, this section assumes
7   that your target system is arm-none-eabi, as indicated by the
8   <code class="command">arm-none-eabi</code> command prefix.
9  </p><p>
10   Using an editor (such as <code class="command">notepad</code> on Microsoft
11   Windows or <code class="command">vi</code> on UNIX-like systems), create a
12   file named <code class="filename">main.c</code> containing the following
13   simple factorial program:
14   </p><pre class="programlisting">#include &lt;stdio.h&gt;
15
16int factorial(int n) {
17  if (n == 0)
18    return 1;
19  return n * factorial (n - 1);
20}
21
22int main () {
23  int i;
24  int n;
25  for (i = 0; i &lt; 10; ++i) {
26    n = factorial (i);
27    printf ("factorial(%d) = %d\n", i, n);
28  }
29  return 0;
30}
31</pre><p>
32  </p><p>
33   Compile and link this program using the command:
34   </p><pre class="screen">&gt; arm-none-eabi-gcc -o factorial main.c -T <em class="replaceable"><code>script</code></em></pre><p>
35   Sourcery CodeBench requires that you specify a linker script with the 
36   <code class="option">-T</code> option to build applications for bare-board targets.
37   Linker errors like <code class="literal">undefined reference to `read'</code>
38   are a symptom of failing to use an appropriate linker script.
39   Default linker scripts are provided in <code class="filename">arm-none-eabi/lib</code>.
40   <span class="phrase">
41     Refer to <a class="xref" href="chap-cs3.html" title="Chapter�5.�CS3&#8482;: The CodeSourcery Common Startup Code Sequence">Chapter�5, &#8220;CS3&#8482;: The CodeSourcery Common Startup Code Sequence&#8221;</a> for information
42     about the boards and linker scripts supported by Sourcery CodeBench Lite.
43     You must also add the processor options for your board, as documented
44     in that chapter, to your compile and link command lines.
45   </span>
46  </p><p>
47   There should be no output from the compiler.  (If you are building a
48   C++ application, instead of a C application, replace
49   <code class="command">arm-none-eabi-gcc</code> with
50   <code class="command">arm-none-eabi-g++</code>.)
51  </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.8.�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>
52