Add environment variable Arm-linux-gcc__linux

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.