A compiler is a program that turns source code into executable code.
Like all programs, a compiler runs on a specific type of computer, and
the new programs it generates also run on a specific type of computer.
The computer on which the compiler runs on is called the host, and the computer the new programs run on is called the target. When the host and target are the same type of machine, the compiler is a native compiler. When the host and target are different, the compiler is a cross compiler.
In our case Friendly ARM is the Target device & PC/Laptop is the Host.We’ve to install the Cross Compiler on the Host to enable deploying programs on to the target FriendlyARM device.In this post I shall explain the process of cross compiler installation on a Linux (Ubuntu 12.04) running Host Computer.
To start with copy the Linux directory from the DVD supplied along with the Friendly ARM device.Paste it to the /tmp directory of File system.
Open up the Terminal type cd / & go to root.Change directory to /tmp/linux by typing
cd /tmp/linux
Type ls command to list out the contents.
arm-linux-gcc-4.4.3.tar.gz is the file we’ve to unTar.
Enter the following command to untar the linux-gcc file.
Use sudo to be a super user .Also note the capital letter C , a space after it & a forward slash /
Type in your super user password.
The command line arguments we use with tar command are x , v , z , & f.
x is to extract/restore contents of tar file.
v is Verbose output i.e, to display the files being restored from tar file
z is to use zip/gzip to read or restore from tar file.
f is to specify the filename used to tar out from
This command will extract arm-linux-gcc to the directory /opt/FriendlyArm/toolschain/4.4.3
To run the compiler you’ve to add the PATH to the compiler environment variable of the system.
Change directory to Root cd / & then go to bin directory by typing
cd /opt/FriendlyArm/4.4.3/bin
We’ve to edit the hidden system file .bashrc ( a ‘ . ‘ indicates that it is a hidden file) & add the PATH at the end of file.
To do that type sudo gedit /root/.bashrc
Type your super user password.
.bashrc file will open up.Scroll down to the end of file & add the path as
export PATH=$PATH:/opt/FriendlyArm/toolschain/4.4.3/bin
& save it.
To Restart shell ,type source ~/.bashrc or you’ve to logout & login back.
(Note the usage of ~ for root )
The Cross Compile environment has been successfully installed.
Type echo $PATH to verify the installation path.
Now type arm-none-linux-gnueabi-cc –v
Note that the gnu compiler make use of EABI , the new Embedded Application Binary Interface.
The compilation process is perfect you will see the following screen.
Now you are ready to cross compile your C code.
No comments:
Post a Comment