12

There are three system names that the build knows about: the machine you are building on (build), the machine that you are building for (host), and the machine that GCC will produce code for (target). When you configure GCC, you specify these with ‘--build=’, ‘--host=’, and ‘--target=’.

Aren't the machine that you are building for and the machine that GCC will produce code for the same thing? What's the difference?

Ned
  • 2,142
  • 17
  • 24
asker
  • 2,159
  • 3
  • 22
  • 27
  • possible duplicate of [What's the difference of `./configure` option `--build`, `--host` and `--target`?](http://stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target) – Steve-o Aug 17 '11 at 06:20

2 Answers2

14

It's possible to build gcc as a cross compiler. That is, you can build a gcc that runs on one architecture (the host) but generates code for a different architecture (the target).

The common place you'll come across this is when building code for embedded platforms. If you're writing code for the processor in your fridge, you'd kind of like to build it on your desktop, not in the fridge!

Some folks use cross compilers to build code for a different OS on the same architecture. For example, it's possible to target Windows from a Linux host with the MinGW toolchain.

Ned
  • 2,142
  • 17
  • 24
  • 1
    so, for the fridge analogy, the host is our desktop and target is the fridge? Pls correct me if I'm wrong – linvenuza Dec 28 '16 at 04:39
  • 1
    eh .. came up with this post and just want to say that it seems to be a wrong answer.. If we are preparing gcc as a compiler for the fridge, then host=fridge will be appropriate. I am confused now because there are 7 up votes to this. – infoclogged Mar 24 '17 at 09:37
  • 2
    build = where am I compiling the compiler, host = where the compiler will run, target = what code will the compiler produce. If I am on my desktop building a new compiler that will run on my desktop and generate code for my fridge, then build=desktop, host=desktop, target=fridge. – Ned Mar 24 '17 at 20:15
1

As per "Configure Terms" the different between "host" and "target" only applies to building a GCC cross compiler for a different machine.

http://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html

Steve-o
  • 12,678
  • 2
  • 41
  • 60