Open In App

What is Cross Compiler?

Compilers are the tool used to translate high-level programming language to low-level programming language. The simple compiler works in one system only, but what will happen if we need a compiler that can compile code from another platform, to perform such compilation, the cross compiler is introduced. In this article, we are going to discuss cross-compiler. 

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a cross compiler executes on machine X and produces machine code for machine Y.



Where is the cross compiler used?

T-Diagram for Cross-compiler

A compiler is characterized by three languages: 

  1. The source language that is compiled.
  2. The target language T is generated.
  3. The implementation language that is used for writing the compiler. 

How does cross-compilation work?

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. In paravirtualization, one computer runs multiple operating systems and a cross compiler could generate an executable for each of them from one main source.

Working of Cross-Compiler

What are the phases of the compiler?

  1. Lexical Analysis.
  2. Syntactic Analysis (i.e. Parsing)
  3. Intermediate Code Generation (and semantic analysis)
  4. Optimization (optional)
  5. Code Generation.

How compiler is different from a cross-compiler?

The native compiler is a compiler that generates code for the same platform on which it runs and on the other hand, a Cross compiler is a compiler that generates executable code for a platform other than one on which the compiler is running. Check out this article for more information Difference between Native compilers and Cross compilers.



Article Tags :