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

來源:互聯網
上載者:User
交叉編譯 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.


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.