使用当前平台的 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
复制内核头文件
[arm@localhost kernel]#su root
[root@localhost kernel]#mkdir p ${SYSROOT}/usr/include
[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]#
译编 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 寻找库的搜索路径。
编译 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]#
编译完整的 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
说明:
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]#
编译完整的 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]#
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步