sh 为armv7-a构建gcc交叉编译器(Cortex-A)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 为armv7-a构建gcc交叉编译器(Cortex-A)相关的知识,希望对你有一定的参考价值。

#!/bin/sh

# Download binutils, gcc, the linux kernel, glibc

# define the prefix
export PREFIX=/opt/armhf

# change PATH to include the target directory
export PATH=$PREFIX/bin:$PATH

# Build binutils
cd ~/tmp/binutils
./configure --prefix=$PREFIX --target=arm-linux-gnueabihf --with-arch=armv7a --with-fpu=vfp --with-float=hard --disable-multilib
make -j$(nproc)
make install

# Install the Linux kernel headers
cd ~/tmp/linux
make ARCH=arm INSTALL_HDR_PATH=$PREFIX/arm-linux-gnueabihf headers_install

# Build gcc (first phase)
cd ~/tmp/gcc
./contrib/download_prerequisites
mkdir build; cd build
../configure --prefix=$PREFIX --target=arm-linux-gnueabihf --enable-languages=c,c++ --with-arch=armv7-a --with-fpu=vfp --with-float=hard --disable-multilib --disable-bootstrap
make -j4 all-gcc
make install-gcc

# Build glibc (first phase)
cd ~/tmp/glibc
mkdir build; cd build
../configure --prefix=$PREFIX/arm-linux-gnueabihf --build=$MACHTYPE --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-arch=armv7a --with-fpu=vfp --with-float=hard --with-headers=$PREFIX/arm-linux-gnueabihf/include --disable-multilib libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make -j4 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/arm-linux-gnueabihf/lib
arm-linux-gnueabihf-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PREFIX/arm-linux-gnueabihf/lib/libc.so
touch $PREFIX/arm-linux-gnueabihf/include/gnu/stubs.h

# Build gcc (second phase, libgcc)
cd ~/tmp/gcc/build
make -j4 all-target-libgcc
make install-target-libgcc

# Build glibc (second phase)
cd ~/tmp/glibc/build
make -j4
make install

# Build libstdc++
cd ~/tmp/gcc/build
make -j4
make install

以上是关于sh 为armv7-a构建gcc交叉编译器(Cortex-A)的主要内容,如果未能解决你的问题,请参考以下文章

构建GCC作为Raspberry-Pi的交叉编译器

构建GCC作为Raspberry-Pi的交叉编译器

sh 为ffmpeg静态编译和交叉编译构建脚本

如何构建GCC交叉编译器

如何构建GCC交叉编译器

如何构建MIPS交叉编译工具链