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
1.1k views
in Technique[技术] by (71.8m points)

cross compiling - What's the difference of "./configure" option "--build", "--host" and "--target"?

The script ./configure accepts 3 options --build, --host and --target. I'm confusing their roles. What's the difference and semantics of them?

Question&Answers:os

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

1 Reply

0 votes
by (71.8m points)

As noted in this blog post and alluded to in the GCC Configure Terms, --target only applies when you are compiling toolchains. When you are doing normal cross-compilation of a library or binary you use

--build=the architecture of the build machine
--host=the architecture that you want the file to run on

However, when you are building toolchains, things can get more complicated. I think that the following is correct (though I can't say I've ever manually compiled a cross-debugger):

Lets say that you have:

  • a powerpc build machine that you are going to do all compilation on
  • several embedded devices, with mips processors, which your code is going to run on
  • an x86 laptop that you are going to use for debugging these devices in the field

You would configure and build your debugging server (eg gdbserver) to run on your embedded device with

./configure --build=powerpc --host=mips

so that you could putty on to your embedded device and run "gdbserver :1234 a.out" to start debugging and listen on port 1234.

You would then build your debugging client (which connects to and controls the gdbserver) with

./configure --build=powerpc --host=i686 --target=mips 

which you would copy to your x86 laptop so that in the field you could run "gdbclient embedded.device:1234" in order to debug your a.out program.

This all applies to compilers too for which you might want to look at the GCC link above or this section about the Canadian cross compile.

Also note that, in practice, you might not see build, host or target specified because, according to this Autoconf manual page, "target defaults to host, host to build, and build to the result of config.guess."

In a word, build the code on --build, run it on --host with --target architecture environment.


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

...