Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
522 views
in Technique[技术] by (71.8m points)

cross compiling - What's the difference between --host and --target in gcc?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...