GNU交叉工具链

 
GNU 交叉工具链
 
1 设置环境变量,准备源码及相关补丁
 
1.1 设置环境变量
[arm@localhost arm] #vi ~/.bashrc
export PREFIX=/usr/local/arm/3.4.4
export TARGET=armlinux
export SYSROOT=${PREFIX}/sysroot
export ARCH=arm
export CROSS_COMPILE=${TARGET}export
PATH=${PREFIX}/bin:$PATH
export SRC=/home/arm/dev_home/btools/tchain3.4.4
1. 2 准备源码包
1.2.1 binuils
名称: binutils2.16.
tar.gz
下载地址: http://ftp.gnu.org/gnu/binutils/binutils2.16.
tar.gz
1.2.2 gcc
名称: gcc3.4.4.
tar.bz2
下载地址: http://ftp.gnu.org/gnu/gcc/gcc3.4.4/
gcc3.4.4.
tar.bz2
1.2.3 glibc
名称: glibc2.3.5.
tar.gz
glibclinuxthreads2.3.5.
tar.gz
下载地址 : http://ftp.gnu.org/gnu/glibc/glibc2.3.5.
tar.gz
http://ftp.gnu.org/gnu/glibc/glibclinuxthreads2.3.5.
tar.gz
1.2.4 linux kernel
名称: linux2.6.14.1.
tar.gz
25
下载地址 : http://ftp.kernel.org/pub/linux/kernel/v2.6/linux2.6.14.1.
tar.gz
1.3 准备补丁
1.3.1 ioperm.c.diff
作用:打修正 ioperm() 函数 .
下载地址: http://frank.harvard.edu/~coldwell/toolchain/ioperm.c.diff
1.3.2 flow.c.diff
作用:该补丁用于产生 crti.o crtn.o 文件。
下载地址: http://gcc.gnu.org/cgibin/
cvsweb.cgi/gcc/gcc/flow.c.diff?cvsroot=gcc&only_with_tag=cslarmbranch&
r1=1.563.4.2&r2=1.563.4.3
1.3.3 t-linux.diff
作用:修改 gcc 一处 bug
下载地址: http://frank.harvard.edu/~coldwell/toolchain/tlinux.
diff
1.4 编译 GNU binutils
重新以 arm 用户登陆,让新设置的环境变量起作用 .
[arm@localhost arm]#su arm
[arm@localhost arm]#cd ${SRC}
[arm@localhost tchain3.4.4]#tar xzvf binutils2.16.
tar.gz
[arm@localhost tchain3.4.4]#mkdir p
BUILD/binutils2.16
[arm@localhost binutils2.16]#
cd BUILD/binutils2.16
[arm@localhost binutils2.16]#
../../binutils2.16/
configure prefix=${
PREFIX} target=${
TARGET} /
withsysroot=${
SYSROOT}
[arm@localhost binutils2.16]#
make
[arm@localhost binutils2.16]#
su root
[root@localhost binutils2.16]#
make install
[root@localhost binutils2.16]#
exit
[arm@localhost binutils2.16]#
1.5 准备内核头文件
1.5.1 使用当前平台的 gcc 编译内核头文件
[arm@localhost tchain3.4.4] #cd ${KERNEL}
[arm@localhost kernel]#tar xvfz linux2.6.14.1.
tar.gz
[arm@localhost kernel]#cd linux2.6.14.1
[arm@localhost linux2.6.14.1]#
make ARCH=arm menuconfig
[arm@localhost linux2.6.14.1]#
make
1.5.2 复制内核头文件
[arm@localhost kernel]#su root
[root@localhost kernel]#mkdir p
${SYSROOT}/usr/include
26
[root@localhost kernel]#cp a
include/linux ${SYSROOT}/usr/include/linux
[root@localhost kernel]#cp a
include/asmi386
${SYSROOT}/usr/include/asm
[root@localhost kernel]#cp a
include/asmgeneric
${SYSROOT}/usr/include/asmgeneric
[root@localhost kernel]#exit
[arm@localhost kernel]#
1.6 译编 glibc 头文件
[arm@localhost kernel]#cd ${SRC}
[arm@localhost chain3.4.4]#tar xvfz glibc2.3.5.
tar.gz
[arm@localhost chain3.4.4]#patch d
glibc2.3.5
p1
< ioperm.c.diff
[arm@localhost glibc2.3.5]#
cd glibc2.3.5
[arm@localhost glibc2.3.5]#
tar xvfz ../glibclinuxthreads2.3.5.
tar.gz
[arm@localhost chain3.4.4]#cd ..
[arm@localhost chain3.4.4]#mkdir BUILD/glibc2.3.5headers
[arm@localhost chain3.4.4]#cd BUILD/glibc2.3.5headers
[arm@localhost glibc2.3.5headers]#../../
glibc2.3.5/
configure prefix=/
usr host=${
TARGET} /
enableaddons=
linuxthreads withheaders=${
SYSROOT}/usr/include
[arm@localhost glibc2.3.5headers]#
su root
[root@localhost glibc2.3.5headers]#
make crosscompiling=
yes install_root=${SYSROOT} installheaders
[root@localhost glibc2.3.5headers]#
touch ${SYSROOT}/usr/include/gnu/stubs.h
[root@localhost glibc2.3.5headers]#
touch ${SYSROOT}/usr/include/bits/stdio_lim.h
[root@localhost glibc2.3.5headers]#
exit
[arm@localhost glibc2.3.5headers]#
注意 : prefix=/
usr : gcc 寻找库的搜索路径。
1.7 编译 gcc 第一阶段
[arm@localhost glibc2.3.5headers]#
cd ${SRC}
[arm@localhost chain3.4.4]#tar xjvf gcc3.4.4.
tar.bz2
[arm@localhost chain3.4.4]#patch d
gcc3.4.4
p1
< flow.c.diff
[arm@localhost chain3.4.4]#patch d
gcc3.4.4
p1
< tlinux.
diff
[arm@localhost chain3.4.4]#mkdir p
BUILD/gcc3.4.4stage1
[arm@localhost chain3.4.4]#cd BUILD/gcc3.4.4stage1
[arm@localhost gcc3.4.4stage1]#../../
gcc3.4.4/
configure prefix=${
PREFIX} target=${
TARGET} /
enablelanguages=
c withsysroot=${
SYSROOT}
注意:不能加上 "disableshared"
选项。
[arm@localhost gcc3.4.4stage1]#
make allgcc
[arm@localhost gcc3.4.4stage1]#
su root
[root@localhost gcc3.4.4stage1]#
make installgcc
[root@localhost gcc3.4.4stage1]#
exit
[arm@localhost gcc3.4.4stage1]#
1.8 编译完整的 glibc
[arm@localhost gcc3.4.4stage1]
#cd ${SRC}
[arm@localhost tchain3.4.4]#mkdir BUILD/glibc2.3.5
[arm@localhost tchain3.4.4]#cd BUILD/glibc2.3.5
[arm@localhost glibc2.3.5]#
BUILD_CC=gcc CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar /
RANLIB=${CROSS_COMPILE}ranlib AS=${CROSS_COMPILE}as LD=${CROSS_COMPILE}ld /
../../glibc2.3.5/
configure prefix=/
usr build=
i386redhatlinux
host=
armunknownlinuxgnu
/
target=
armunknownlinuxgnu
without__
thread enableaddons=
linuxthreads /
withheaders=${
SYSROOT}/usr/include
27
说明:
prefix:
指定安装路径。
target
指定目标平台。
host:
指定当前平台。
build:
指定编译平台。
withsysroot:
用于指定编译所需要的头文件,及链接库。
enableaddons:
加入其它的库,如线程库等。
enablelanguages:
指定 gcc 所支持的语言。
[arm@localhost glibc2.3.5]#
make
[arm@localhost glibc2.3.5]#
su root
[root@localhost glibc2.3.5]#
make install_root=${SYSROOT} install
[root@localhost glibc2.3.5]#
exit
[arm@localhost glibc2.3.5]#
1.9 编译完整的 gcc
[arm@localhost glibc2.3.5]#
cd ${SRC}
[arm@localhost tchain3.4.4]#mkdir BUILD/gcc3.4.4
[arm@localhost tchain3.4.4]#cd BUILD/gcc3.4.4
[arm@localhost gcc3.4.4]#../../
gcc3.4.4/
configure prefix=${
PREFIX} target=${
TARGET} /
enablelanguages=
c withsysroot=${
SYSROOT}
[arm@localhost gcc3.4.4]#
make
[arm@localhost gcc3.4.4]#
su root
[root@localhost gcc3.4.4]#
make install
[root@localhost gcc3.4.4]#
exit
[arm@localhost gcc3.4.4]#
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值