Question

what is cross compilation?

Was it helpful?

Solution

Cross-compilation is the act of compiling code for one computer system (often known as the target) on a different system, called the host.

It's a very useful technique, for instance when the target system is too small to host the compiler and all relevant files.

Common examples include many embedded systems, but also typical game consoles.

OTHER TIPS

To "cross compile" is to compile source on say a Linux box with intent on running it on a MAC or Windows box. This is usually done using a cross compilation plugin, which are readily available from various web servers across the net. If one is to install a cross compilation plugin onto their Linux box that is designed to compile for Windows boxes. Then they may compile for either a Linux/*NIX box as well as have the option to compile and link a Windows-ready executable. This is extremely convenient for a freelance programmer whom has access to no more than a single Linux/Windows/MAC box. Note that various cross compilation plugins will allow for multitudes of applications, some of which you may or may not perceive as useful, thus a thorough perusal of the plugin's README file.

Did you have a particular project in mind that you would like to apply the method of cross compilation to?

A cross-compiler is compiles the source code from one architecture to another architecture.

For example: hello.c

  1. gcc hello.c (gcc is a compiler for x86 architecture.)
  2. arm-cortexa8-linux-gnueabihf-gcc hello.c
    (arm-....-gcc is a compiler for the arm architecture.) This you are compiling on the host pc for a target board (e.g rpi, beaglebone, wega board). In this example arm-cortexa8-linux-gnueabihf-gcc is called the 'cross compiler'.

This process is called cross compilation.
see the link for more info cross compilation

In a strict sense, it is the compilation of code on one host that is intended to run on another.

Most commonly it is used with reference to compilation for architectures that are not binary-compatible with the host -- for instance, building RISC binaries on a CISC CPU platform, or 64-bit binaries on a 32-bit system. Or, for example, building firmware intended to run on embedded devices (perhaps using the ARM CPU architecture) on Intel PC-based OSs.

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 e.g. a compiler that runs on a Windows 7 PC but generates code that runs on Android smartphone is a cross compiler.

A cross compiler is necessary to compile for multiple platforms from one machine.
A platform could be infeasible for a compiler to run on, such as for the microcontroller of an embedded system because those systems contain no operating system.
In paravirtualization one machine runs many operating systems, and a cross compiler could generate an executable for each of them from one main source.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top