Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the exact difference between cross-compiling and native compiling?

share|improve this question

You use a cross compiler to produce executables (or objects) for a platform other than the local host. The native compiler only produces native binaries.

share|improve this answer
Just an additional note. Cross compiling may require some library installation on the target(MSYS possibly) – RobotHumans Feb 7 '11 at 13:46
@aking1012 — I don't think that's necessarily an issue with cross-compiling itself. – mattdm Feb 7 '11 at 17:33
@mattdm - if we are talking cross compiling across architecture it is not. if we are talking about cross compiling from linux to windows...maybe I'm interpreting cross-compiling differently. – RobotHumans Feb 7 '11 at 17:38
@aking1012 — I think it's an implementation detail in either case. – mattdm Feb 7 '11 at 17:53

Cross compiling is compiling something for different CPU type than the one you are running on. An example is compiling ARM binaries under an i386 system, or compiling 64-bit executables under a 32-bit system.

You normally won't be able to run what you've just compiled when you cross compile it, until you ship the binaries to the system they belong to.

Native compiling is when you compile for the same architecture you're running under, which is the normal situation.

share|improve this answer
Cross-compiling is more generally compiling for a different platform, not just a different CPU type. For example, MinGW can be used as a cross-compiler to build MS Windows executables on Linux — x86 in both cases. – mattdm Feb 7 '11 at 17:36
which one is too slow? – Renjith G Feb 8 '11 at 4:51

Cross compiling is building for a platform (roughly, a combination of OS, CPU family and ABI) other than the one you are running on. That means having a compiler that runs on one platform but targets another platform. It generally (there are exceptions to this because some platforms have compatibility layers) means you can't just run the binaries you have just built.

The compiler itself is usually not the big deal in cross-building, the rest of the buildsystem is. The build-system needs to run the correct compiler with the correct options. Many build systems build and run test programs to work out the details of the system they are running on. You can't generally do that if you are cross-building. Many build systems use programs they have built to generate things during the build, this may mean your buildsystem needs to build some stuff for the platform you are bulding on, some stuff for the platform you are building for and potentially some stuff for both.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.