1.代码结构为:
setup ---》 源代码压缩包
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/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 --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)
-
Linux
+关注
关注
87文章
11236浏览量
209024 -
开发工具链
+关注
关注
0文章
12浏览量
1584
发布评论请先 登录
相关推荐
评论