./configure配置的参数 交叉编译 host build target的含义(转)

来源:互联网 发布:淘宝促销模板代码 编辑:程序博客网 时间:2024/05/01 13:42
交叉编译 host,build target的含义:
build就是你正在使用的机器,host就是你编译好的程序可以运行的平台,
target就是你编译的程序可以处理的平台.
这个 build和host比较好理解,但是target就不好办了,到底什么意思呢?
一般来说,我们平时所说的交差编译用不到他target的,
比如. /configure --build=i386-linux,--host=arm-linux就可以了,在386的平台上编译可以运行在arm板的程序.


今天阅读autobook[注1]一书,3.4节讲到了configuration name。
书中提到了build、host、target这几个变量。看起来容易让人感到一些混淆,其实这极大的简化了二进制文件格式生成的控制。
build -- 在build系统中建立package host -- 建立好package后,package能够在host运行 target -- 经由package所产生的可执行文件能够在target上运行。
例如: 在GNU/Linux系统上交叉编译一个可以在AIX机器上运行的package。
那么 build = i*86-pc-linux-gnu host = rs6000-ibm-aix3.2 target = rs6000-ibm-aix3.2
在GNU/Linux系统上建立一个交叉编译工具,
此交叉编译工具可以在AIX上运行,由此交叉编译出来的文件可以在ARM上运行,
那么: build = i*86-pc-linux-gnu host = rs6000-ibm-aix3.2 target = arm-linux 由此可以看出
,当建立一个package时,不必非在本地机器上建立,可以设置不同的configuration name来生成不同系统的package。

注:[1]autobook描述如何使用GNU提供的一系列autotools来管理复杂软件系统的开的。

具体解释一下,build就是你正在使用的机器,host就是你编译好的程序可以运行的平台,target就是你编译的程序可以处理的平台.
这个build和host比较好理解,但是target就不好办了,到底什么意思呢?一般来说,我们平时所说的交差编译用不到他target的
,比如./configure --build=i386-linux,--host=arm-linux就可以了,在386的平台上编译可以运行在arm板的程序.但是,一般我们都是编译程序,而不是编译工具,如果我们编译工具,
比如gcc,这个target就有用了.如果我们需要在一个我们的机器上为arm开发板编译一个可以处理mips程序的gcc,那么target就是mips了.不知道我的解释是否正确,如果大家看到了这篇帖子,觉得不对,批评指正.

原文地址 http://oss.lzu.edu.cn/blog/blog.php?/do_showone/tid_116.html


Reference:
http://www.tcpdump.org/lists/workers/2001/11/msg00148.html

Nope. See `info standards' for the definition of $build*, $host* and
$target* macros. Basically, $build* refer to the system compilation is
being performed on, $host* refer to the system compiled binaries are to
run on and $target* refer to the system compiled binaries will handle. As
such $target* usually have a meaning a meaning for developemt tool only.
So far packages that make use of $target* I know of are binutils, gcc,
gdb and ksymoops (a Linux run-time error disassembler). Let's take
binutils as an example. I compile it in several ways, following are

examples of configure invocations:
 
1. `./configure --build=mipsel-linux --host=mipsel-linux
--target=mipsel-linux' will build native mipsel-linux binutils on
mipsel-linux.
 
2. `./configure --build=i386-linux --host=mipsel-linux
--target=mipsel-linux' will cross-build native mipsel-linux binutils on
i386-linux.
 
3. `./configure --build=i386-linux --host=i386-linux
--target=mipsel-linux' will build mipsel-linux cross-binutils on
i386-linux.
 
4. `./configure --build=mipsel-linux --host=i386-linux
--target=mipsel-linux' will cross-build mipsel-linux cross-binutils for
i386-linux on mipsel-linux.
As you see, only if $build != $host a cross-compilation is performed.

原创粉丝点击