CROSS COMPILERS

 CROSS COMPILERS:

In Embedded System, mostly we develop codes for micro-controllers by using IDLE’s on Desktop or Laptop. So here the Host is our Laptop/Desktop and the Target is Micro-Controller.

Before explaining about cross compiling I would like to brief about

What is compilation?

Compilation is a process to convert our high level or middle level language code (let say C language) to machine understandable code (hex file).

Now I am trying to explain about cross compilation…

Normally micro-controllers are differ in their architectures. Our Desktop and Laptop having 32/64 bit Processors. So if you compile one code from your 64 bit Laptop using normal compiler (let say GCC compiler for C language), that will generate hex file ( compiled output ) which is understandable only for that 64 bit processor. That means you can execute your code only in your Laptop/Desktop. Here the Host and Target are same. So no need to use cross compilers.

Let us think about another scenario like, you want to run your code in other Processor ( may be in Raspberry Pi (ARM Architecture)) not in your Laptop/Desktop. But you developed that code from your 64 bit Laptop. you can’t use same hex file in Raspberry Pi which you compiled by normal gcc compiler. If you try to run that same hex file, it will throw an error like exec format error or binary format error.

  1. -bash: ./a.out: cannot execute binary file: Exec format error 

So here Host is our Laptop/Desktop and the Target is Raspberry Pi .

Here the actual role of cross compiler comes into picture. Cross compilers will generate hex files for Target architecture from Host. So the cross compiler generated hex file will not run in your Laptop/Desktop ( Host ) . But it will run in Raspberry Pi ( Target ).

Comments

Popular posts from this blog

VLSI (CMOS LATCH UP)

VLSI (STATIC POWER CONSUMPTION IN CMOS)