configure交叉編譯

來源:互聯網
上載者:User

交叉編譯某個應用程式時,通常需要 ./configure 來產生對應的 Makefile
./configure 最關鍵的三個選項是:

--host=HOST
指定軟體啟動並執行系統平台.如果沒有指定,將會運行`config.guess'來檢測.

--build=BUILD
指定軟體包安裝的系統平台.如果沒有指定,預設值將是'--host'選項的值.

--target=GARGET
指定軟體面向(target to)的系統平台.這主要在程式語言工具如編譯器和彙編器上下文中起作用.如果沒有指定,預設將使用'--host'選項的值.

一般而言,我們只要指定 --host 就可以了
記住:--host 指定的是交叉編譯工具鏈的首碼

##################################################################################################################################

在 i686 開發機上交叉編譯出 ethtool,讓其在powerpc開發板上運行

1.下載原始碼並解壓
#cd /home/wanghui/
#tar xvfz ethtool-6.tar.gz
#cd ethtool-6

2.交叉編譯
確保交叉編譯工具鏈的bin檔案在PATH環境變數裡
#echo $PATH
/usr/local/bin:/bin:/usr/bin:/opt/montavista41/montavista/cge/devkit/ppc/85xx/bin/:/home/wanghui/bin
#./configure --host=ppc-linux
#make

3.查看組建檔案
#file ethtool
ethtool: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped

shit! 交叉編譯失敗,腫麼還是X86的bin檔案,肯定是configure出了問題,導致Makefile用的不是交叉編譯工具鏈的gcc

4.查看config.log

有這麼一句:
configure:1790: checking for ppc-linux-gcc
configure:1819: result: no
configure:1828: checking for gcc
configure:1844: found /usr/bin/gcc

我擦,沒找到ppc-linux-gcc
cd /opt/montavista41/montavista/cge/devkit/ppc/85xx/bin
到裡面一看,崩潰了,原來是 ppc_85xx-gcc,所有bin檔案首碼是 ppc_85xx

5.重新交叉編譯
#./configure --host=ppc_85xx
#make

6.查看組建檔案
#file ethtool
ethtool: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.4.17, dynamically linked (uses shared libs), not stripped

查看cofig.log
configure:1662: checking for ppc_85xx-strip
configure:1678: found /opt/montavista41/montavista/cge/devkit/ppc/85xx/bin//ppc_85xx-strip
configure:1688: result: ppc_85xx-strip
configure:1757: checking whether to enable maintainer-specific portions of Makefiles
configure:1766: result: no
configure:1790: checking for ppc_85xx-gcc
configure:1806: found /opt/montavista41/montavista/cge/devkit/ppc/85xx/bin//ppc_85xx-gcc
configure:1816: result: ppc_85xx-gcc

7.把ethtool檔案放到開發板下運行,OK

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.