title: Building ARM GNU Cross compiler
body: <p>A similiar (less descriptive) post is <a href="https://stackoverflow.com/questions/338559/building-gnuarm-toolchain-from-source">here</a>.</p>
  
  <p>I'm trying to roll my own tool chain using recent releases on Ubuntu and was hoping there was enough of a Linux community here that I could get specific advice on certain problems as they come up.  </p>
  
  <p>With everyone's help I'd like to see this turn into a useful reference eventually.</p>
  
  <p>First off "<a href="http://kegel.com/crosstool/" rel="nofollow noreferrer">Crosstool</a>" to which nearly everyone refers is a little (2006) out of date and "<a href="http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool" rel="nofollow noreferrer">Crosstool-NG</a>" which seems to now be carrying the torch fails on my machine.  I'd rather debug the process itself than a script (which it would seem requires me to understand the process).</p>
  
  <p>Below are basic steps of what I've got working so far; at present I'm stuck trying to compile the first pass GCC.  </p>
  
  <p><strong>Where it's failing ...</strong> </p>
  
  <p>It's failing because the cross compiled library containing "crti.o" is missing:</p>
  
  <pre><code># ./gcc-4.4.1/configure --target=arm-linux --disable-thread --enable-langauges=c 
  /bin/bash ../../../gcc-4.4.1/libgcc/../mkinstalldirs .
  /usr/src/gnu-4.4.1-build/./gcc/xgcc -B ........
  /usr/local/arm-linux/bin/ld: crti.o No such file: No such file or directory
  collect2: ld returned 1 exit status
  make[2]: *** [libgcc_s.so] Error 1
  make[2]: Leaving directory `/usr/src/gnu/gcc-4.4.1-build/arm-linux/libgcc'
  make[1]: *** [all-target-libgcc] Error 2
  make[1]: Leaving directory `/usr/src/gnu/gcc-4.4.1-build'
  make: *** [all] Error 2
  </code></pre>
  
  <p><strong><em>Build steps</em></strong></p>
  
  <p>On a 'freshly' configured Ubuntu 9.04 installation, here are the steps I've done so far:</p>
  
  <pre><code>#New configuration of Ubuntu 9.04
  sudo updatedb
  sudo apt-get install build-essential subversion
  # For kernel configuration
  sudo apt-get install libncurses5-dev
  # For building GCC
  sudo apt-get install libgmp3-dev libmpfr-dev
  
  #Get Linux Headers for GCC/GLIBC compilations
  # I use a hacked Linux from Artilla, 
  pushd ~ &amp;&amp; svn co http://.../linux m501-linux &amp;&amp; cd !$
  make ARCH=arm m501_defconfig
  make ARCH=arm menuconfig
  sudo mkdir /usr/local/arm-linux/include
  sudo cp -dR include/asm-arm /usr/local/arm-linux/include/asm
  sudo cp -dR include/linux /usr/local/arm-linux/include/linux
  cd /usr/local/arm-linux/
  sudo ln -s include sys-include
  popd
  
  #Get sources:
  cd /usr/src/
  sudo su root
  mkdir gnu
  ftp ftp.gnu.org
  # get gnu/binutils/binutils-2.19.1.tar.bz2
  # get gnu/gcc/gcc-4.4.1/gcc-4.4.1.tar.bz2
  # get gnu/glibc/glibc-2.10.1.tar.bz2
  # get gnu/gdb/gdb-6.8.tar.bz2
  
  #Build Binutils
  bzcat binutils-2.19.1.tar.bz2 | tar -xv
  mkdir binutils-2.19.1-build &amp;&amp; cd !$
  cp ../binutils-2.19.1/gas/config/tc-arm.c ./tc-arm.c 
  sed -r 's/(as_bad[ \t]*\()(.+\[.+\]\))/\1\"%s\",\2/' &lt; ./tc-arm.c &gt; ../binutils-2.19.1/gas/config/tc-arm.c 
  rm ./tc-arm.c    
  ../binutils-2.19.1/configure --target=arm-linux
  make &amp;&amp; make install &amp;&amp; cd ..
  
  #Build GCC
  bzcat gcc-4.4.1.tar.bz2 | tar -xv
  mkdir gcc-4.4.1-build &amp;&amp; cd !$
  ../gcc-4.4.1/configure --target=arm-linux --disable-thread --enable-langauges=c -with-headers=/usr/local/arm-linux/include
  make
  </code></pre>