构建交叉编译链arm-linux-gnueabihf-

构建交叉编译链arm-linux-gnueabihf-

终于......成功了....

首先感谢http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/

再加个参考网址保险点,以前看这个一直没能成功...现在懂了...:

http://wiki.osdev.org/GCC_Cross-Compiler


需要先下载下列包,换过其他版本,都失败过...我也是醉了...

wget http://ftpmirror.gnu.org/binutils/binutils-2.24.tar.gz

wget http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz

wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.4.79.tar.xz

wgethttp://ftpmirror.gnu.org/glibc/glibc-2.20.tar.xz

wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.2.tar.xz

wget http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.xz

wget http://ftpmirror.gnu.org/mpc/mpc-1.0.2.tar.gz

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz



Build Steps

先解压缩所有压缩包:

for f in *.tar*; do tar xf $f; done

(涨知识了...)


把 mpfr,gmp,mpc,isl,cloog放到gcc目录下:

cd gcc-4.9.2

ln -s ../mpfr-3.1.2 mpfr

ln -s ../mpc-1.0.2 mpc

ln -s ../isl-0.12.2 isl

ln -s ../cloog-0.18.1 cloog

cd ..


然后再创建一个交叉编译根目录:

sudo mkdir -p /opt/cross

sudo chown -R 777 /opt/cross


申明环境变量:

export PREFIX=/opt/cross

export PATH=/opt/cross/bin:$PATH

export TARGET=arm-linux-gnueabihf


ok,开始主要步奏

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

Step 1:构建Binutils

mkdir build-binutils

cd build-binutils

../binutils-2.24/configure --prefix=$PREFIX --target=$TARGET --disable-multilib

make -j8

sudo make install

cd ..


Step 2:Linux Kernel Headers

cd linux-3.4.79

sudo make ARCH=arm INSTALL_HDR_PATH=/opt/cross/$TARGET headers_install

cd ..


Step 3:C/C++ Compilers

mkdir build-gcc

cd build-gcc

../gcc-4.9.2/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ --disable-multilib

make -j8 all-gcc

sudo make install-gcc

cd ..


Step 4:Standard C Library Headers and Startup Files

mkdir -p build-glibc

cd build-glibc

../glibc-2.20/configure --prefix=/opt/cross/$TARGET --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=/opt/cross/$TARGET/include --disable-multilib libc_cv_forced_unwind=yes

sudo make install-bootstrap-headers=yes install-headers

sudo make -j8 csu/subdir_lib

sudo install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross/$TARGET/lib

sudo $TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/cross/$TARGET/lib/libc.so

sudo touch /opt/cross/$TARGET/include/gnu/stubs.h

cd ..


Step 5:Compiler Support Library

cd build-gcc

sudo make -j8 all-target-libgcc

sudo make install-target-libgcc

cd ..


Step 6:Standard C Library

cd build-glibc

sudo make -j8

sudo make install

cd ..


Step 7:Standard C++ Library

cd build-gcc

sudo make -j8

sudo make install

cd ..






转载于:https://www.cnblogs.com/weibingkitty/p/4446555.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值