opensource codes configure and compile with toolchain

来源:互联网 发布:java reflection 实例 编辑:程序博客网 时间:2024/05/17 08:13

./configure -build,-host,-target设置


build:执行代码编译的主机,正常的话就是你的主机系统。这个参数一般由config.guess来猜就可以。当然自己指定也可以。

host:编译出来的二进制程序所执行的主机,因为绝大多数是如果本机编译,本机执行。所以这个值就等于build。只有交叉编译的时候(也就是本机编译,其他系统机器执行)才会build和host不同。用host指定运行主机。

总的来说,只有host !=build的时候编译才是交叉编译。否则就是正常编译。


交叉编译某个应用程序时,通常需要 ./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



========================================================================================

编译iperf:

./configure --prefix="install dir" --host="交叉编译器的前缀"

make

make install

编译iw:

编译libnl

./configure --prefix="install dir" --host="交叉编译器的前缀(arm-linux)"

make

make install

进入iw目录

export PKG_CONFIG_PATH=./install/lib/pkgconfig:$PKG_CONFIG_PATH

make CC=arm-linux-gcc

编译busybox:

make defconfig

将交叉编译器的路径加入到环境变量PATH中

make CROSS_COMPILE=arm-linux-

0 0
原创粉丝点击