linux如何安装交叉工具链,Linux:制作mipsel 交叉工具链 (更新版)

1.代码结构为:

setup ---》 源代码压缩包

241b745d33e10dc2d1750e76edda7586.png

src ---》源码

~/code/cross-compile$ ls src/

binutils-2.24 gcc-4.7.1 gdb-7.6.2 glibc-2.18

build --》 编译目录

:~/code/cross-compile$ ls build/

binutils gcc gdb glibc

kernel ----》 内核代码:

~/code/cross-compile/kernel$ ls

linux-3.10

2.编译 binutils

在build/binutils 下,执行命令:

。./。./src/binutils-2.24/configure --target=mipsel-linux-gnueabi --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain

然后,执行 make, make install 安装

3. 编译 GCC stage 1

在 build/gcc目录下,执行

AR=ar LDFLAGS=“-Wl,-rpath=/home/charles/code/cross-compile/embedded-toolchain/cross-tools/lib” 。./。./src/gcc-4.7.1/configure --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --target=mipsel-linux-gnueabi --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain --with-gmp=/usr/local --with-mpfr=/usr/local --with-ppl=/usr/local --with-newlib --without-headers --disable-multilib --disable-nls --disable-decimal-float --disable-libgomp --disable-libmudflap --disable-libssp --disable-shared --disable-threads --enable-languages=c --with-float=soft --with-arch=mips32r2 --with-tune=mips32r2

然后,

make all-gcc all-target-libgcc

make install-gcc install-target-libgcc

4. 安装内核头文件

进入到内核代码目录,

执行命令:

ARCH=mips make mrproper

ARCH=mips make headers_check

ARCH=mips CROSS_COMPILE=mipsel-gcc-linux-gnueabi make INSTALL_HDR_PATH=/home/charles/code/cross-compile/embedded-toolchain/usr headers_install

find /home/charles/code/cross-compile/embedded-toolchain/usr/include/ -name “.install” -or -name “。.install.cmd” | xargs rm -fv ;\

5. 编译 GLIBC

进入到 build/glibc,执行

BUILD_CC=gcc CC=mipsel-linux-gnueabi-gcc AR=mipsel-linux-gnueabi-ar RANLIB=mipsel-linux-gnueabi-ranlib 。./。./src/glibc-2.18/configure --prefix=/usr --host=mipsel-linux --enable-add-ons --with-fp=no libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_ctors_header=yes --with-tune=mips32r2 --with-arch=mips32r2 --with-headers=/home/charles/code/cross-compile/embedded-toolchain/usr/include

把步骤3生成的mipsel gcc 加入到 path:

export PATH=$PATH:/home/charles/code/cross-compile/embedded-toolchain/cross-tools/bin

执行

make

make install install_root=/home/charles/code/cross-compile/embedded-toolchain

6.编译最后的GCC

AR=ar LDFLAGS=“-Wl,-rpath=/home/c++harles/code/cross-compile/embedded-toolchain/cross-tools/lib” 。./。./src/gcc-4.7.1/configure --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --target=mipsel-linux-gnueabi --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain --with-gmp=/usr/local --with-mpfr=/usr/local --with-ppl=/usr/local --disable-multilib --disable-libssp --disable-nls --disable-libstdcxx-pch --with-arch=mips32r2 --with-tune=mips32r2 --enable-languages=c,c++ --with-float=soft --with-mips-plt --disable-libgomp --disable-libmudflap --enable-poison-system-directories --enable-symvers=gnu --enable-long-long --enable-threads --enable-shared --enable-lto --enable-__cxa_atexit --with-gnu-as --with-gnu-ld

再执行

make all-gcc -j10 -i -k

make all-target-libgcc

make install-gcc

make install-target-libgcc

make

make install

最后,看一下生成的gcc的信息:

。/mipsel-linux-gnueabi-gcc -v

Using built-in specs.

COLLECT_GCC=。/mipsel-linux-gnueabi-gcc

COLLECT_LTO_WRAPPER=/home/charles/toolchain/embedded-toolchain/cross-tools/bin/。./libexec/gcc/mipsel-linux-gnueabi/4.7.1/lto-wrapper

Target: mipsel-linux-gnueabi

Configured with: 。./。./src/gcc-4.7.1/configure --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --target=mipsel-linux-gnueabi --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain --with-gmp=/usr/local --with-mpfr=/usr/local --with-ppl=/usr/local --disable-multilib --disable-libssp --disable-nls --disable-libstdcxx-pch --with-float=soft --with-arch=mips32r2 --with-tune=mips32r2 --enable-languages=c,c++ --with-float=soft --with-mips-plt --disable-libgomp --disable-libmudflap --enable-poison-system-directories --enable-symvers=gnu --enable-long-long --enable-threads --enable-shared --enable-lto --enable-__cxa_atexit --with-gnu-as --with-gnu-ld

Thread model: posix

gcc version 4.7.1 (GCC)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值