Difference between revisions of "ARM Cross Compiler"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
Line 67: Line 67:
 
<font color="red">For a gnueabi distro (Lenny)</font>
 
<font color="red">For a gnueabi distro (Lenny)</font>
 
  cd build-arm-linux-gnueabi
 
  cd build-arm-linux-gnueabi
  ./configure --target=arm-linux-gnueabi --prefix=/usr/local/arm-linux-gnueabi --with-sysroot=/usr/local/arm-linux-gnueabi --with-local-prefix=/usr/local/arm-linux-gnueabi/arm-linux-gnueabi --enable-nls  --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++,fortran --enable-shared --enable-c99 --enable-long-long  --with-system-zlib  --enable-mpfr --disable-libssp --disable-sjlj-exceptions  
+
  ../configure --target=arm-linux-gnueabi --prefix=/usr/local/arm-linux-gnueabi --with-sysroot=/usr/local/arm-linux-gnueabi --with-local-prefix=/usr/local/arm-linux-gnueabi/arm-linux-gnueabi --enable-nls  --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++,fortran --enable-shared --enable-c99 --enable-long-long  --with-system-zlib  --enable-mpfr --disable-libssp --disable-sjlj-exceptions  
  
 
(Some of the options were taken from the crosstool chain configuration provided by embeddedarm.com, they can also be found on the compiler of the target system, ask it with "gcc -v")
 
(Some of the options were taken from the crosstool chain configuration provided by embeddedarm.com, they can also be found on the compiler of the target system, ask it with "gcc -v")
 +
 +
'''Make sure you DO NOT have . in your PATH''', this will at some point pick the wrong tools when compiling. If you get a funny "as: unrecognized option `-Qy'" error, you are using the wrong assembler. Check your PATH, try again.
  
 
Compile and install:
 
Compile and install:

Revision as of 11:38, 28 August 2009

Cross Compile Chain for ARM system TS-7390

Some hints were taken from: http://www.ethernut.de/en/documents/cross-toolchain-osx.html However, this does not work right for the TS arm platforms. These instructions worked for me with a TS-7390 board.

These instructions worked on both Mac OS X 10.5 and Red Hat Linux 5.3

Get the sources

Sources obtained from:

curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-core-4.2.2.tar.bz2
curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-g++-4.2.2.tar.bz2
curl -O ftp://sourceware.org/pub/gdb/releases/gdb-6.7.1.tar.bz2

GNU Build instructions at: http://gcc.gnu.org/install/build.html

Untar in the ~/crosscompile/ directory or some other location of choice.

Prepare the sysroot

Presumably you want to compile code on your host system for some target system. If this target system runs Linux, you'd want to be able to access all the libraries and header files from the target system on your host system. Otherwise, why bother with a cross compiler.

On the target system, create a includes.tgz from /usr/includes and libs.tgz from /usr/libs and liblibs.tgz from /lib:

 tar czvf /tmp/includes.tgz /usr/include
 tar czvf /tmp/libs.tgz         /usr/lib  /lib

On the host, expand these in the new sysroot for the target.

mkdir /usr/local/arm-linux-gnu/
cd /usr/local/arm-linux-gnu/
tar xzvf ~/include.tgz 
tar xzvf ~/libs.tgz

You should now have a copy of the relevant libraries in your /usr/local/arm-linux-gnu directory.

FIRST MAKE THE BINUTILS

On the host, go to binutils directory (where you untarred the binutils tar file, then cd into binutils-2-18), create a build-arm-linux subdirectory (mkdir build-arm-linux), and run:

For a gnu distro (Etch)

 cd build-arm-linux-gnu
 ../configure --target=arm-linux-gnu  --prefix=/usr/local/arm-linux-gnu --with-sysroot=/usr/local/arm-linux-gnu --with-local-prefix=/usr/local/arm-linux-gnu/arm-linux-gnu --disable-nls --with-gcc --with-gnu-as --with-gnu-ld 

For a gnueabi distro (Lenny)

 cd build-arm-linux-gnueabi
 ../configure --target=arm-linux-gnueabi  --prefix=/usr/local/arm-linux-gnueabi --with-sysroot=/usr/local/arm-linux-gnueabi --with-local-prefix=/usr/local/arm-linux-gnueabi/arm-linux-gnueabi --disable-nls --with-gcc --with-gnu-as --with-gnu-ld 

(Note for Mac: Check that makeinfo points to makeinfo or /usr/bin/makeinfo and not the Tex version!)

Compile and install:

make
make install

Compile GCC

On the host, go to gcc-4.2.2 directory (where you untarred gcc-4.2.2, then cd into gcc-4.2.2 directory) and configure with:

mkdir build-arm-linux-gnu

For a gnu distro (Etch)

cd build-arm-linux
../configure --target=arm-linux-gnu --prefix=/usr/local/arm-linux-gnu --with-sysroot=/usr/local/arm-linux-gnu --with-local-prefix=/usr/local/arm-linux-gnu/arm-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long 

For a gnueabi distro (Lenny)

cd build-arm-linux-gnueabi
../configure --target=arm-linux-gnueabi --prefix=/usr/local/arm-linux-gnueabi --with-sysroot=/usr/local/arm-linux-gnueabi --with-local-prefix=/usr/local/arm-linux-gnueabi/arm-linux-gnueabi --enable-nls  --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++,fortran --enable-shared --enable-c99 --enable-long-long  --with-system-zlib  --enable-mpfr --disable-libssp --disable-sjlj-exceptions 

(Some of the options were taken from the crosstool chain configuration provided by embeddedarm.com, they can also be found on the compiler of the target system, ask it with "gcc -v")

Make sure you DO NOT have . in your PATH, this will at some point pick the wrong tools when compiling. If you get a funny "as: unrecognized option `-Qy'" error, you are using the wrong assembler. Check your PATH, try again.

Compile and install:

make 
make install

The compiler and everything needed should now be installed in /usr/local/arm-linux-gnu/bin. Add this to your path and run these versions as "arm-linux-gnu-gcc" etc.