本文主机环境为Ubuntu10.04.4桌面版
内核:2.6.32
GCC:4.4.3
---------------------------------------------------转载请注明:xiaobin_hlj80----
Z.前期准备(使用root权限)
一、安装系统补丁
1. 安装更新189个(2012-10-8)
二、网络
1. 安装ssh,apt-get install ssh
远程控制用
2. 安装samba
文件共享用
三、软件环境
安装如下软件(apt-get install)
1. bison
2. flex
3. libncurses5-dev
4. build-essential(g++)
5. gperf
6. texinfo
7. automake
8. libtool
9. gawk
update-alternatives --config awk
10. cvs
11.subversion(svn)
12. zlib1g-dev
13.libexpat-dev(cross-gdb)
Y. 安装crosstool-ng
1.解压缩
# tar jxvf crosstool-ng-1.16.0.tar.bz2
2.配置
# ./configure --prefix=/usr/local/ctng
3.生成
# make
4.安装
# make install
X. 配置crosstool-ng
1. 增加安装路径到系统路径中
export PATH=$PATH:/usr/local/ctng/bin
2. 建立一个临时目录
# cd ~
root@xiaobin-pc:~# mkdir toolchain-build
3. 拷贝预配置文件到临时目录
root@xiaobin-pc:/# cd /usr/local/ctng/lib/ct-ng.1.16.0/samples
root@xiaobin-pc:/usr/local/ctng/lib/ct-ng.1.16.0/samples# cp arm-unknown-linux-gnueabi/* ~/toolchain-build/
# cd ~
root@xiaobin-pc:~# cd crosstool-build
root@xiaobin-pc:~/toolchain-build# mvcrosstool.config .config
4. 执行菜单配置(menuconfig)
此步为修改默认选项,以适应我们的目标板。
(1) 更改shell为bash
如果运行
# ls -la /bin/sh
看到链接的是 dash ,则请运行以下命令
sudo dpkg-reconfigure dash
选择 no 以删除 dash
(2)root@xiaobin-pc:~/toolchain-build#ct-ng menuconfig
a. Paths and misc options
1)crosstool-NG behavior
默认
2)Paths
默认
3)Downloading
默认
4)Extracting
默认
5)Build behavior
(2) Number of parallel jobs
6)Logging
默认
b. Target options
Target Architecture (arm)
1)Generic target options
2)Target optimizations
3)arm other options
c. Toolchain options
1)General toolchain options
2)Tuple completion and aliasing
3)Toolchain type
4)Build system
5)Misc options
d. Operating System
Linux kernel version (2.6.32.59)
1)Common kernel options
2)linux other options
e. Binary utilities
Binuary format: (ELF)
1)GNU binutils
Binutils version (2.19.1a)
2)elf2flt
f. C compiler
C compiler (gcc)
gcc version (4.4.3)
1)Additional supported languages
2)gcc other options
3)Optimisation features
4)Settings for libraries running on target
5)Misc. obscure options
g. C-library
C library (glibc)
glibc version (2.9)
h. Debug facilities
i. Companion libraries
GMP version (4.3.2)
MPFR version (2.4.2)
PPL version (0.10.2)
CLooG/ppl version (0.15.9)
1)libelf version needed to build for target
libelf version (0.8.13)
2)Companion libraries common options
j. Companion tools
k. Test suite
5. 下载文件
此步是为了节省下载时间,我们使用下载工具把文件(bz2)下载下来,然后拷贝到$HOME/src(默认目录)下。
(1) linux-2.6.32.59.tar.bz2
(2) gcc-4.4.3.tar.bz2
(3) binutils-2.19.1a.tar.bz2
(4) mpfr-2.4.2.tar.bz2
(5) gmp-4.3.2.tar.bz2
(6) ppl-0.10.2.tar.bz2
(7) gdb-6.8a.tar.bz2
(8) expat-2.0.1.tar.gz
(9) strace-4.5.19.tar.bz2
(10) cloog-ppl-0.15.9.tar.gz
(11) dmalloc-5.5.2.tgz
(12) libelf-0.8.13
(13) duma-2_5_15
(14) ltrace_0.5.3.orig.tar.gz
(15)ncurses-5.9.tar.gz
(16)glibc-2.9.tar.bz2
(17)glibc-ports-2.9.tar.bz2
6. 生成交叉编译环境
root@xiaobin-pc:~/toolchain-build# ct-ngbuild
7. 测试
root@xiaobin-pc:~/toolchain-build# cd .. root@xiaobin-pc:~# ls src toolchain-build x-tools root@xiaobin-pc:~# cd x-tools root@xiaobin-pc:~/x-tools# ls arm-unknown-linux-gnueabi root@xiaobin-pc:~/x-tools# cd arm-unknown-linux-gnueabi root@xiaobin-pc:~/x-tools/arm-unknown-linux-gnueabi# cd bin root@xiaobin-pc:~/x-tools/arm-unknown-linux-gnueabi/bin# ls arm-unknown-linux-gnueabi-addr2line arm-unknown-linux-gnueabi-gdbtui arm-unknown-linux-gnueabi-ar arm-unknown-linux-gnueabi-gprof arm-unknown-linux-gnueabi-as arm-unknown-linux-gnueabi-ld arm-unknown-linux-gnueabi-c++ arm-unknown-linux-gnueabi-ldd arm-unknown-linux-gnueabi-cc arm-unknown-linux-gnueabi-nm arm-unknown-linux-gnueabi-c++filt arm-unknown-linux-gnueabi-objcopy arm-unknown-linux-gnueabi-cpp arm-unknown-linux-gnueabi-objdump arm-unknown-linux-gnueabi-ct-ng.config arm-unknown-linux-gnueabi-populate arm-unknown-linux-gnueabi-g++ arm-unknown-linux-gnueabi-ranlib arm-unknown-linux-gnueabi-gcc arm-unknown-linux-gnueabi-readelf arm-unknown-linux-gnueabi-gcc-4.4.3 arm-unknown-linux-gnueabi-size arm-unknown-linux-gnueabi-gccbug arm-unknown-linux-gnueabi-strings arm-unknown-linux-gnueabi-gcov arm-unknown-linux-gnueabi-strip arm-unknown-linux-gnueabi-gdb root@xiaobin-pc:~/x-tools/arm-unknown-linux-gnueabi/bin# ./arm-unknown-linux-gnueabi-gcc -v Using built-in specs. Target: arm-unknown-linux-gnueabi Configured with: /root/toolchain-build/.build/src/gcc-4.4.3/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-unknown-linux-gnueabi --prefix=/root/x-tools/arm-unknown-linux-gnueabi --with-sysroot=/root/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --enable-languages=c,c++ --with-float=soft --with-pkgversion='crosstool-NG 1.16.0' --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --with-gmp=/root/toolchain-build/.build/arm-unknown-linux-gnueabi/buildtools --with-mpfr=/root/toolchain-build/.build/arm-unknown-linux-gnueabi/buildtools --with-ppl=/root/toolchain-build/.build/arm-unknown-linux-gnueabi/buildtools --with-cloog=/root/toolchain-build/.build/arm-unknown-linux-gnueabi/buildtools --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-nls --disable-multilib --with-local-prefix=/root/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --enable-c99 --enable-long-long Thread model: posix gcc version 4.4.3 (crosstool-NG 1.16.0) root@xiaobin-pc:~/x-tools/arm-unknown-linux-gnueabi/bin#
---------------------------------------------------------------美丽的分割线----------------------
如果不安装下面两个的话//(ㄒoㄒ)//
zlib1g-dev:
会出现无法找到zlib.h(zlib.h: No such file or directory).
参照:http://www.linuxsir.org/bbs/thread355152.html
libexpat-dev:
安装了2个多小时提示,
[INFO ] ================================================================= [INFO ] Installing cross-gdb [EXTRA] Configuring cross-gdb [EXTRA] Building cross-gdb [ERROR] configure: error: expat is missing or unusable [ERROR] make[2]: *** [configure-gdb] Error 1 [ERROR] make[1]: *** [all] Error 2 [ERROR] / [ERROR] >> [ERROR] >> Build failed in step 'Installing cross-gdb' [ERROR] >> called in step '(top-level)' [ERROR] >> [ERROR] >> Error happened in: CT_DoExecLog[scripts/functions@172] [ERROR] >> called from: do_debug_gdb_build[scripts/build/debug/300-gdb.sh@159] [ERROR] >> called from: do_debug[scripts/build/debug.sh@35] [ERROR] >> called from: main[scripts/crosstool-NG.sh@598] [ERROR] >> [ERROR] >> For more info on this error, look at the file: 'build.log' [ERROR] >> There is a list of known issues, some with workarounds, in: [ERROR] >> '/usr/local/ctng/share/doc/crosstool-ng/ct-ng.1.16.0/B - Known issues.txt' [ERROR] / [ERROR] (elapsed: 124:43.25) [124:44] / make: *** [build] Error 2
---------------------------------------------------------------美丽的分割线----------------------
在./configure时,会出现几个“no”,如下所示:
root@xiaobin-desktop:/home/xiaobin/setup/crosstool-ng-1.16.0# ./configure --prefix=/usr/local/ctng
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking whether sed understands -r -i -e... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for ranlib... ranlib
checking for objcopy... objcopy
checking for absolute path to objcopy... /usr/bin/objcopy
checking for objdump... objdump
checking for absolute path to objdump... /usr/bin/objdump
checking for readelf... readelf
checking for absolute path to readelf... /usr/bin/readelf
checking for bison... bison
checking for flex... flex
checking for gperf... gperf
checking for makeinfo... makeinfo
checking for cut... cut
checking for stat... stat
checking for readlink... readlink
checking for wget... wget
checking for tar... tar
checking for gzip... gzip
checking for bzip2... bzip2
checking for patch... /usr/bin/patch
checking for bash >= 3.1... /bin/bash
checking for GNU awk... /usr/bin/awk
checking for GNU make >= 3.80... /usr/bin/make
checking whether /usr/bin/make sets $(MAKE)... yes
checking for GNU libtool >= 1.5.26... /usr/bin/libtool
checking for GNU libtoolize >= 1.5.26... /usr/bin/libtoolize
checking for GNU automake >= 1.10... /usr/bin/automake
checking for xz... xz
checking for cvs... cvs
checking for svn... svn
checking for inline... inline
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking for working alloca.h... yes
checking for alloca... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking whether gettext is declared... yes
checking ncurses/ncurses.h usability... no
checking ncurses/ncurses.h presence... no
checking for ncurses/ncurses.h... no
checking ncurses/curses.h usability... no
checking ncurses/curses.h presence... no
checking for ncurses/curses.h... no
checking ncursesw/curses.h usability... no
checking ncursesw/curses.h presence... no
checking for ncursesw/curses.h... no
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for library containing initscr... -lncurses
configure: creating ./config.status
config.status: creating Makefile
root@xiaobin-desktop:/home/xiaobin/setup/crosstool-ng-1.16.0#
解决:忽略之!
---------------------------------------------------------------美丽的分割线----------------------
最后,贴出over的:
root@xiaobin-pc:~/toolchain-build# ct-ng build [INFO ] Performing some trivial sanity checks [INFO ] Build started 20121009.200246 [INFO ] Building environment variables [EXTRA] Preparing working directories [EXTRA] Installing user-supplied crosstool-NG configuration [EXTRA] ================================================================= [EXTRA] Dumping internal crosstool-NG configuration [EXTRA] Building a toolchain for: [EXTRA] build = i686-pc-linux-gnu [EXTRA] host = i686-pc-linux-gnu [EXTRA] target = arm-unknown-linux-gnueabi [EXTRA] Dumping internal crosstool-NG configuration: done in 0.33s (at 00:17) [INFO ] ================================================================= [INFO ] Retrieving needed toolchain components' tarballs [INFO ] Retrieving needed toolchain components' tarballs: done in 0.57s (at 00:18) [INFO ] ================================================================= [INFO ] Extracting and patching toolchain components [INFO ] Extracting and patching toolchain components: done in 2.30s (at 00:20) [INFO ] ================================================================= [INFO ] Installing GMP for host [EXTRA] Configuring GMP [EXTRA] Building GMP [EXTRA] Installing GMP [INFO ] Installing GMP for host: done in 331.71s (at 05:52) [INFO ] ================================================================= [INFO ] Installing MPFR for host [EXTRA] Configuring MPFR [EXTRA] Building MPFR [EXTRA] Installing MPFR [INFO ] Installing MPFR for host: done in 70.29s (at 07:02) [INFO ] ================================================================= [INFO ] Installing PPL for host [EXTRA] Configuring PPL [EXTRA] Building PPL [EXTRA] Installing PPL [INFO ] Installing PPL for host: done in 666.86s (at 18:09) [INFO ] ================================================================= [INFO ] Installing CLooG/PPL for host [EXTRA] Configuring CLooG/ppl [EXTRA] Building CLooG/ppl [EXTRA] Installing CLooG/ppl [INFO ] Installing CLooG/PPL for host: done in 18.87s (at 18:28) [INFO ] ================================================================= [INFO ] Installing binutils for host [EXTRA] Configuring binutils [EXTRA] Building binutils [EXTRA] Installing binutils [INFO ] Installing binutils for host: done in 234.95s (at 22:23) [INFO ] ================================================================= [INFO ] Installing pass-1 core C compiler [EXTRA] Configuring core C compiler [EXTRA] Building core C compiler [EXTRA] Installing core C compiler [INFO ] Installing pass-1 core C compiler: done in 509.17s (at 30:52) [INFO ] ================================================================= [INFO ] Installing kernel headers [EXTRA] Installing kernel headers [EXTRA] Checking installed headers [INFO ] Installing kernel headers: done in 15.55s (at 31:08) [INFO ] ================================================================= [INFO ] Installing C library headers & start files [EXTRA] Configuring C library [EXTRA] Installing C library headers [EXTRA] Installing C library start files [INFO ] Installing C library headers & start files: done in 130.23s (at 33:18) [INFO ] ================================================================= [INFO ] Installing pass-2 core C compiler [EXTRA] Configuring core C compiler [EXTRA] Building core C compiler [EXTRA] Installing core C compiler [INFO ] Installing pass-2 core C compiler: done in 569.12s (at 42:47) [INFO ] ================================================================= [INFO ] Installing C library [EXTRA] Configuring C library [EXTRA] Building C library [EXTRA] Installing C library [INFO ] Installing C library: done in 2104.58s (at 77:52) [INFO ] ================================================================= [INFO ] Installing final compiler [EXTRA] Configuring final compiler [EXTRA] Building final compiler [EXTRA] Installing final compiler [INFO ] Installing final compiler: done in 966.51s (at 93:59) [INFO ] ================================================================= [INFO ] Installing libelf for the target [EXTRA] Configuring libelf [EXTRA] Building libelf [EXTRA] Installing libelf [INFO ] Installing libelf for the target: done in 15.31s (at 94:14) [INFO ] ================================================================= [INFO ] Installing binutils for target [EXTRA] Configuring binutils for target [EXTRA] Building binutils' libraries (libiberty bfd) for target [EXTRA] Installing binutils' libraries (libiberty bfd) for target [INFO ] Installing binutils for target: done in 276.20s (at 98:50) [INFO ] ================================================================= [INFO ] Installing dmalloc [EXTRA] Configuring dmalloc [EXTRA] Building dmalloc [EXTRA] Installing dmalloc [INFO ] Installing dmalloc: done in 27.61s (at 99:18) [INFO ] ================================================================= [INFO ] Installing D.U.M.A. [EXTRA] Copying sources [EXTRA] Building libraries 'libduma.a libduma.so.0.0.0' [EXTRA] Installing libraries 'libduma.a libduma.so.0.0.0' [EXTRA] Installing shared library link [EXTRA] Installing wrapper script [INFO ] Installing D.U.M.A.: done in 4.52s (at 99:22) [INFO ] ================================================================= [INFO ] Installing cross-gdb [EXTRA] Configuring cross-gdb [EXTRA] Building cross-gdb [EXTRA] Installing cross-gdb [INFO ] Installing cross-gdb: done in 438.62s (at 106:41) [INFO ] ================================================================= [INFO ] Installing native gdb [EXTRA] Building static target ncurses [EXTRA] Building static target expat [EXTRA] Configuring native gdb [EXTRA] Building native gdb [EXTRA] Installing native gdb [EXTRA] Cleaning up ncurses [INFO ] Installing native gdb: done in 840.62s (at 120:42) [INFO ] ================================================================= [INFO ] Installing gdbserver [EXTRA] Configuring gdbserver [EXTRA] Building gdbserver [EXTRA] Installing gdbserver [INFO ] Installing gdbserver: done in 26.35s (at 121:08) [INFO ] ================================================================= [INFO ] Installing ltrace [EXTRA] Copying sources to build dir [EXTRA] Configuring ltrace [EXTRA] Building ltrace [EXTRA] Installing ltrace [INFO ] Installing ltrace: done in 9.97s (at 121:18) [INFO ] ================================================================= [INFO ] Installing strace [EXTRA] Configuring strace [EXTRA] Building strace [EXTRA] Installing strace [INFO ] Installing strace: done in 42.10s (at 122:00) [INFO ] ================================================================= [INFO ] Cleaning-up the toolchain's directory [INFO ] Stripping all toolchain executables [EXTRA] Installing the populate helper [EXTRA] Installing a cross-ldd helper [EXTRA] Creating toolchain aliases [EXTRA] Removing access to the build system tools [INFO ] Cleaning-up the toolchain's directory: done in 6.30s (at 122:07) [INFO ] Build completed at 20121009.220452 [INFO ] (elapsed: 122:05.45) [INFO ] Finishing installation (may take a few seconds)... [122:07] / root@xiaobin-pc:~/toolchain-build#