1. Download the Cross compiler
ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/
Select cross-3.2.tar.bz2 or cross-3.2.tar.gz (I choose cross-3.2.tar.gz here)
arm-linux-gcc-3.4.1.tar.bz2
http://www.handhelds.org/download/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
2. Unpack the package installation
Put the cross-3.2.tar.gz in/below directly unpack (because cross-3.2.tar.gz package itself unpack the directory structure is/usr/local/arm, so can not put cross-3.2.tar.gz to/sur/ Below the local to unpack the package)
[Root@localhost/] #tar xvzf cross-3.2-tar.gz
The arm directory can be seen under/usr/local:
[Root@localhost/]# cd/usr/local
[Root@localhost local]# ls
Arm bin etc Games include Lib Libexec sbin share src
3. Add cross compiler environment variable (three methods a,b)
A.[root@localhost local]# export path= $PATH:/usr/local/arm/bin Note: (This method works only at the current terminal)
B. Modify the/etc/profile file:
[Root@localhost local]# Vi/etc/profile
Add at the end: Export path= $PATH:/usr/local/arm/bin
C. Modify the ~/.bash_profile file:
[Root@localhost local]# VI ~/.basn_profile
Modified: path= $PATH: Usr/local/arm/bin
4. Make the new environment variable effective.
(b)----[root@localhost Local] #source/etc/profile
or (c)-----[root@localhost Local] #source ~/.basn_profile
5. Check if you want to add path
[Root@localhost local]# Echo $PATH
If there is a/usr/local/arm/bin in the display, the path of the cross compiler is added. Since then, the cross-compilation environment has been built.
6. Test
Simple example:
[Root@localhost Local] #vi hello.c
--Input:
/*hello.c*/
#intclude <stdio.h>
int main ()
{
printf ("hello,world!/n");
return 0;
}
--Save Exit VI
[Root@localhost Local] #arm-linux-gcc hello.c-o Hello
[Root@localhost local]# ls
Arm bin etc Games Hello hello.c include Lib libexec sbin share src
--Successfully generated Hello file
[Root@localhost local]#./hello
BASH:./hello:cannot Execute binary file
--hint that the binaries cannot be executed
--file Hello file type
[root@localhost local]# file Hello
Hello:elf 32-bit LSB executable, ARM, version 1 (ARM), for Gnu/linux 2.0.0, dynamically linked (Usesshared Libs), not str ipped
--see no, executable arm system file
7.ARM-LINUX-GCC Cross compilation environment to build success.