天天看點

./configure配置的參數 交叉編譯 host build target的含義(轉)

交叉編譯 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.

繼續閱讀