OpenEmbedded有两种方式来得到toolchain,一种是build from scratch,也就是用oe自身的一套来产生toolchain,然后用这套toolchain去编译其他的package.另外一种就是使用第三方 (3rd)的toolchain-编译好的来编译其他的package。
在上篇文章中,我们说过可以使用oe(bitbake meta-toolchain)会编译出一个toolchain,我就用这个toolchain作为第三方toolchain来编译package
1 toolchain的组织结构
lynn@OEBP i486 \> pwd
/usr/local/angstrom/i486
lynn@OEBP i486 \> ls -l
total 60
drwxr-xr-x 2 root root 4096 2009-03-21 19:04 bin
-rw-r--r-- 1 root root 718 2009-03-21 19:04 environment-setup
drwxr-xr-x 3 root root 4096 2009-03-21 19:04 etc
drwxr-xr-x 7 root root 4096 2009-03-21 19:04 i486-angstrom-linux
drwxr-xr-x 3 root root 4096 2009-03-21 19:04 i686-linux
drwxr-xr-x 3 root root 4096 2009-03-21 19:04 include
drwxr-xr-x 5 root root 4096 2009-03-21 19:04 lib
drwxr-xr-x 3 root root 4096 2009-03-21 19:04 libexec
drwxr-xr-x 9 root root 4096 2009-03-21 19:04 share
-rw-r--r-- 1 root root 12800 2009-03-21 19:04 site-config
drwxr-xr-x 3 root root 4096 2009-03-21 19:04 usr
-rw-r--r-- 1 root root 140 2009-03-21 19:04 version
lynn@OEBP i486 \> cd bin/
lynn@OEBP bin \> ls
i486-angstrom-linux-addr2line i486-angstrom-linux-gdbtui i486-angstrom-linux-strings
i486-angstrom-linux-ar i486-angstrom-linux-gprof i486-angstrom-linux-strip
i486-angstrom-linux-as i486-angstrom-linux-infocmp i486-angstrom-linux-tic
i486-angstrom-linux-captoinfo i486-angstrom-linux-infotocap i486-angstrom-linux-toe
i486-angstrom-linux-c++filt i486-angstrom-linux-ld i486-angstrom-linux-tput
i486-angstrom-linux-clear i486-angstrom-linux-nm i486-angstrom-linux-tset
i486-angstrom-linux-cpp i486-angstrom-linux-objcopy libtool
i486-angstrom-linux-g++ i486-angstrom-linux-objdump libtoolize
i486-angstrom-linux-gcc i486-angstrom-linux-ranlib opkg-cl
i486-angstrom-linux-gccbug i486-angstrom-linux-readelf opkg-key
i486-angstrom-linux-gcov i486-angstrom-linux-reset pkg-config
i486-angstrom-linux-gdb i486-angstrom-linux-size update-alternatives
库文件和头文件位于
lynn@OEBP usr \> pwd
/usr/local/angstrom/i486/i486-angstrom-linux/usr
lynn@OEBP usr \> ls
bin include lib libexec sbin share
2设置toolchain路径
TOOLCHAIN=/usr/local/angstrom/i486/bin
export PATH=${TOOLCHAIN}:${PATH}
3 设置TOOLCHAIN变量
CC,CXX,CPP,LD,AR,AS,STRIP,RANLIB
export CC = "${HOST_PREFIX}gcc ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
export CXX = "${HOST_PREFIX}g++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
export CPP = "${HOST_PREFIX}gcc -E${TOOLCHAIN_OPTIONS}"
export LD = "${HOST_PREFIX}ld${TOOLCHAIN_OPTIONS}"
export CCLD = "${CC}"
export AR = "${HOST_PREFIX}ar"
export AS = "${HOST_PREFIX}as"
export RANLIB = "${HOST_PREFIX}ranlib"
export STRIP = "${HOST_PREFIX}strip"
export OBJCOPY = "${HOST_PREFIX}objcopy"
export OBJDUMP = "${HOST_PREFIX}objdump"
由于toolchain的prefix和目前一样,所以在这里就不用修改这些变量的值了,否则必须修改,比如:
export CC = "arm-linux-gcc"
然后再把 3rd toolchain的头文件和库文件添加到路径中去
PRE_BUILT = "/usr/local/angstrom/i486/i486-angstrom-linux/usr"
TARGET_CPPFLAGS_append = " -I${PRE_BUILT}/include "
TARGET_LDFLAGS_prepend = " -L${PRE_BUILT}/qt2/lib -L${PRE_BUILT}/lib -Wl,-rpath-link,${PRE_BUILT}/lib -Wl,-rpath-link,${PRE_BUILT}/qt2/lib "
4 移去toolchain的依赖
在default的情况下,oe会自动build 一套最简单的toolchain,也就是gcc和glibc,现在使用了第三方toolchain,所以现在就不必要去编译,在你的local.conf中指定
ASSUME_PROVIDED += " virtual/${TARGET_PREFIX}gcc "
ASSUME_PROVIDED += " virtual/libc "
5测试
bitbake helloworld
你会发现就不会去build gcc binutils glibc等等
阅读(1641) | 评论(0) | 转发(0) |