構建交叉編譯鏈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 ..







免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM