How to setup a cross compiler

From IGEP - ISEE Wiki

Revision as of 10:58, 21 August 2012 by Pau (talk | contribs)

Jump to: navigation, search

Overview

Cross-development in general, refers to the overall software development process that eventually produces a single application or a complete system running on an platform that is different from the development platform. This is accomplished using a cross-compiler toolchain and cross-compiled libraries.

Peter Seebach defines cross-compilation as follows: "Cross compilation occurs when a compiler running on one system produces executables for another system -- this is an important concept when the target system doesn't have a native set of compilation tools, or when the host system is faster or has greater resources."

Cross-development usually involves two different platforms, the host platform where actual development work takes place, and the target platform where the final application is tested and run.

IGEP SDK provides all necessary tools like a cross compiler, embedded libraries, etc. to compile program sources for IGEP devices.

IGEP SDK is included in IGEP SDK Virtual Machine but you can install in other Linux operating system.

Download/Install IGEP SDK

Download IGEP SDK from isee.biz website and follow the next steps:

  • Open a terminal
  • Located your downloaded file, in my case is inside /home/Downloads:
jdoe@ubuntu ~ $ cd Downloads/
  • Extract binaries in root directory with root privileges
jdoe@ubuntu ~/Downloads $ sudo tar jxf igep-sdk-yocto-toolchain-*.tar.bz2 -C /
  • Make sure that binaries are installed correctly.
jdoe@ubuntu ~/Downloads $ ls /opt/poky/
1.2  1.2.1 

Use IGEP SDK

IGEP SDK can be integrated with multiple IDEs, but the simplest method to prove it is using terminal:

  • Create source code text file:

First of all you need to initialize a suitable environment in the bash shell console inside your machine.
You can do this sourcing once the environment-setup script.

jdoe@ubuntu ~ $ source /opt/poky/1.2/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi 

Create a single .c file (hello-world.c), using your preferred editor (vi, nano, gedit, ...)
hello-world.c:

#include <stdio.h> 
int main (int argc, char **argv)
{
  printf("Hello world !\n");
  return 0;
}
  • Build arm binary executable:

Cross toolchain tools are available into the built-in virtual machine Poky SDK. You only need open bash terminal prompt and write commands:

jdoe@ubuntu ~/Desktop $ arm-poky-linux-gnueabi-gcc -o hello-world hello-world.c
  • Check binary created:
jdoe@ubuntu ~/Desktop $ file hello-world
hello-world: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
  • Transfer arm executable file from virtual machine to IGEP Board
  • Execute arm executable file inside IGEP Board (remote shell):
root@igep00x0:~# ./hello-world 
Hello world !

Other Cross compilers for IGEP Boards

Linaro Toolchain

Information.jpg Tested in Ubuntu 12.04.

Install Toolchain

Install Linaro Toolchain in Ubuntu distribution is simple, because it is officially supported at latest releases. Open a terminal and type:

sudo apt-get install cpp-4.5-arm-linux-gnueabi g++-4.5-arm-linux-gnueabi 

For older releases you need to add Linaro Toolchain repositories:

sudo add-apt-repository ppa:linaro-maintainers/toolchain
sudo apt-get install cpp-4.5-arm-linux-gnueabi g++-4.5-arm-linux-gnueabi 

Link Linaro Toolchain 4.5:

sudo ln -f -s /usr/bin/arm-linux-gnueabi-cpp-4.5  /usr/bin/arm-linux-gnueabi-cpp 
sudo ln -f -s /usr/bin/arm-linux-gnueabi-gcov-4.5  /usr/bin/arm-linux-gnueabi-gcov 
sudo ln -f -s /usr/bin/arm-linux-gnueabi-gcc-4.5  /usr/bin/arm-linux-gnueabi-gcc