sudo apt-get install -y git gcc g++ bison gdb binutils bzip2 flex python perl make grep diffutils gettext unzip automake gawk subversion zlib1g-dev libz-dev asciidoc golang curl gperf libtool libtool-bin help2man sed dpkg-dev bison flex patch texinfo automake m4 lzma bison flex texinfo patch gawk python-pip python-m2cryptolibssl1.0.0/jessie libssl-dev/jessie openssl/jessie
mkdir $HOME/build
cd $HOME/build
git clone
cd crosstool-ng
./bootstrap
./configure --prefix=$HOME/.local
make
make install
cd ../
加入~/.profile
echo -ne "\n\nif [ -d "$HOME/.local/bin" ]; then\n PATH="$HOME/.local/bin:$PATH"\nfi" >> ~/.profile
使之生效
source ~/.profile
创建工具链目录
mkdir $HOME/tc/ && cd $HOME/tc/
开始创建工具链并编译,这里以mipsel
为例:
mkdir mipsel-superman-linux-gnu
cd mipsel-superman-linux-gnu
ct-ng mipsel-unknown-linux-gnu
#设置
ct-ng menuconfig
ct-ng build
等编译完,你就得到了mipsel
的交叉编译工具链。
为了方便,我们进入工具目录创建软连接。
cd ${HOME}/x-tools/mipsel-superman-linux-gnu/bin
vi link.sh
输入
#!/bin/sh
PREFIX=mipsel-superman-linux-gnu-
AFTFIX=mipsel-linux-
ln -s ${PREFIX}addr2line ${AFTFIX}addr2line
ln -s ${PREFIX}ar ${AFTFIX}ar
ln -s ${PREFIX}as ${AFTFIX}as
ln -s ${PREFIX}c++ ${AFTFIX}c++
ln -s ${PREFIX}c++filt ${AFTFIX}c++filt
ln -s ${PREFIX}cc ${AFTFIX}cc
ln -s ${PREFIX}cpp ${AFTFIX}cpp
ln -s ${PREFIX}ct-ng.config ${AFTFIX}ct-ng.config
ln -s ${PREFIX}elfedit ${AFTFIX}elfedit
ln -s ${PREFIX}g++ ${AFTFIX}g++
ln -s ${PREFIX}gcc ${AFTFIX}gcc
ln -s ${PREFIX}gcc-6.3.0 ${AFTFIX}gcc-6.3.0
ln -s ${PREFIX}gcc-ar ${AFTFIX}gcc-ar
ln -s ${PREFIX}gcc-nm ${AFTFIX}gcc-nm
ln -s ${PREFIX}gcc-ranlib ${AFTFIX}gcc-ranlib
ln -s ${PREFIX}gcov ${AFTFIX}gcov
ln -s ${PREFIX}gcov-tool ${AFTFIX}gcov-tool
ln -s ${PREFIX}gdb ${AFTFIX}gdb
ln -s ${PREFIX}gprof ${AFTFIX}gprof
ln -s ${PREFIX}ld ${AFTFIX}ld
ln -s ${PREFIX}ld.bfd ${AFTFIX}ld.bfd
ln -s ${PREFIX}ldd ${AFTFIX}ldd
ln -s ${PREFIX}nm ${AFTFIX}nm
ln -s ${PREFIX}objcopy ${AFTFIX}objcopy
ln -s ${PREFIX}objdump ${AFTFIX}objdump
ln -s ${PREFIX}populate ${AFTFIX}populate
ln -s ${PREFIX}ranlib ${AFTFIX}ranlib
ln -s ${PREFIX}readelf ${AFTFIX}readelf
ln -s ${PREFIX}size ${AFTFIX}size
ln -s ${PREFIX}strings ${AFTFIX}strings
ln -s ${PREFIX}strip ${AFTFIX}strip
保存后执行
chmod +x ./link.sh
./link.sh
接着 执行
export PATH="${PATH}:${HOME}/x-tools/mipsel-superman-linux-gnu/bin"
加入系统路径就可以开始交叉编译了。
每次执行交叉编译都要执行上面export这句。
OK,完毕。