Linux arm-linux交叉编译环境的配置
声明来自http://blog.csdn.net/lianyq1986/article/details/6651447
step:
1.配置crosstool
[root@localhost crosstool-ng-1.9.3]# ./configure --prefix=/opt/powerpc/install_dir/
Checking for ‘grep‘... /bin/grep
Checking whether ‘/bin/grep‘ supports -E... yes
Checking for ‘sed‘... /bin/sed
Checking whether ‘/bin/sed‘ supports -i and -e... yes
Checking for ‘bash‘... /bin/bash
Checking for ‘cut‘... /bin/cut
Checking for ‘install‘... /usr/bin/install
Checking for ‘make‘... /usr/bin/make
Checking for ‘gcc‘... /usr/lib/ccache/gcc
Checking for ‘awk‘... /bin/awk
Checking for ‘bison‘... /usr/bin/bison
Checking for ‘flex‘... /usr/bin/flex
Checking for ‘makeinfo‘... /usr/bin/makeinfo
Checking for ‘automake‘... /usr/bin/automake
Checking for ‘libtool‘... /usr/bin/libtool
Checking for ‘stat‘... /usr/bin/stat
Checking for ‘aria2c‘... no
Checking for ‘curl‘... /usr/bin/curl
Checking for ‘cvs‘... /usr/bin/cvs
Checking for ‘patch‘... /usr/bin/patch
Checking for ‘tar‘... /bin/tar
Checking for ‘gzip‘... /bin/gzip
Checking for ‘bzip2‘... /usr/bin/bzip2
Checking for ‘lzma‘... no
lzma: none found
Either you are missing entirely the needed tool,
or the version you have is too old.
configure: Bailing out...
(yum install lzma后继续下一步)
2.配置crosstool
[root@localhost crosstool-ng-1.9.3]# ./configure --prefix=/opt/powerpc/install_dir/
Checking for ‘grep‘... /bin/grep
Checking whether ‘/bin/grep‘ supports -E... yes
Checking for ‘sed‘... /bin/sed
Checking whether ‘/bin/sed‘ supports -i and -e... yes
Checking for ‘bash‘... /bin/bash
Checking for ‘cut‘... /bin/cut
Checking for ‘install‘... /usr/bin/install
Checking for ‘make‘... /usr/bin/make
Checking for ‘gcc‘... /usr/lib/ccache/gcc
Checking for ‘awk‘... /bin/awk
Checking for ‘bison‘... /usr/bin/bison
Checking for ‘flex‘... /usr/bin/flex
Checking for ‘makeinfo‘... /usr/bin/makeinfo
Checking for ‘automake‘... /usr/bin/automake
Checking for ‘libtool‘... /usr/bin/libtool
Checking for ‘stat‘... /usr/bin/stat
Checking for ‘aria2c‘... no
Checking for ‘curl‘... /usr/bin/curl
Checking for ‘cvs‘... /usr/bin/cvs
Checking for ‘patch‘... /usr/bin/patch
Checking for ‘tar‘... /bin/tar
Checking for ‘gzip‘... /bin/gzip
Checking for ‘bzip2‘... /usr/bin/bzip2
Checking for ‘lzma‘... /usr/bin/lzma
Checking for ‘readlink‘... /usr/bin/readlink
Checking for ‘objcopy‘... /usr/bin/objcopy
Checking for ‘objdump‘... /usr/bin/objdump
Checking for ‘readelf‘... /usr/bin/readelf
Checking for ‘patch‘... /usr/bin/patch
Checking for ‘ncurses/ncurses.h‘... yes
Checking for ‘libncursesw.so‘... yes
Computing version string... 1.9.3
Building up Makefile... done
crosstool-NG configured as follows:
PREFIX=‘/opt/powerpc/install_dir/‘
BINDIR=‘/opt/powerpc/install_dir//bin‘
LIBDIR=‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3‘
DOCDIR=‘/opt/powerpc/install_dir//share/doc/ct-ng-1.9.3‘
MANDIR=‘/opt/powerpc/install_dir//share/man‘
Now run:
make
make install
3. 编译
[root@localhost crosstool-ng-1.9.3]# make
SED ‘ct-ng‘
SED ‘scripts/crosstool-NG.sh‘
SED ‘scripts/saveSample.sh‘
SED ‘scripts/showTuple.sh‘
GEN ‘paths.mk‘
SED ‘docs/ct-ng.1‘
GZIP ‘docs/ct-ng.1.gz‘
4. 安装到prefix指定路径
[root@localhost crosstool-ng-1.9.3]# make install
MKDIR ‘/opt/powerpc/install_dir//bin/‘
INST ‘ct-ng‘
RMDIR ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/‘
MKDIR ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/‘
INSTDIR ‘config/‘
INSTDIR ‘contrib/‘
INSTDIR ‘kconfig/‘
INSTDIR ‘patches/‘
INSTDIR ‘scripts/‘
INST ‘steps.mk‘
INST ‘paths.mk‘
INSTDIR ‘samples/‘
MKDIR ‘/opt/powerpc/install_dir//share/doc/ct-ng-1.9.3/‘
INST ‘docs/*.txt‘
MKDIR ‘/opt/powerpc/install_dir//share/man/man1/‘
INST ‘ct-ng.1.gz‘
For auto-completion, do not forget to install ‘ct-ng.comp‘ into
your bash completion directory (usually /etc/bash_completion.d)
5.导入crosstool-ng的安装路径
[root@localhost crosstool-ng-1.9.3]# export PATH=$PATH:/opt/powerpc/install_dir/bin/
[root@localhost crosstool-ng-1.9.3]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/powerpc/install_dir/bin/
6.创建下载路径
[root@localhost crosstool-ng-1.9.3]# mkdir dl
[root@localhost crosstool-ng-1.9.3]# cd dl/
[root@localhost dl]# ls -l
总计 134708
-rwxr-xr-x 1 root root 16245771 08-01 15:24 binutils-2.19.1.tar.bz2
-rw-r--r-- 1 root root 666608 08-01 15:26 dmalloc-5.5.2.tgz
-rw-r--r-- 1 root root 240479 08-01 15:26 duma_2_5_15.tar.gz
-rw-r--r-- 1 root root 44025458 08-01 15:25 gcc-4.2.4.tar.bz2
-rwxr-xr-x 1 root root 15581509 08-01 15:25 gdb-6.8.tar.bz2
-rw-r--r-- 1 root root 1897483 08-01 15:27 gmp-4.3.2.tar.bz2
-rwxr-xr-x 1 root root 52737600 08-01 15:24 linux-2.6.28.10.tar.bz2
-rw-r--r-- 1 root root 1138685 08-01 15:26 mpfr-3.0.0.tar.bz2
-rw-r--r-- 1 root root 2445052 08-01 15:27 ncurses-5.7.tar.gz
-rwxr-xr-x 1 root root 480973 08-01 15:26 strace-4.5.18.tar.bz2
-rw-r--r-- 1 root root 2285137 08-01 15:25 uClibc-0.9.30.1.tar.bz2
(提前准备好需要的软件包)
7.在samples目录下有许多参考的配置文件
[root@localhost crosstool-ng-1.9.3]# cp ppc8541_crosstool.config .config
[root@localhost crosstool-ng-1.9.3]# ./ct-ng menuconfig
(可以对配置进行修改)
Paths and misc options下的配置
Local tarballs directory: /opt/powerpc/crosstool-ng-1.9.3/dl
Prefix directory : /opt/powerpc/crosstool-ng-1.9.3/x-tools/${CT_TARGET}
(4) Number of parallel jobs
Target options下的配置
(8540) Emit assembly for CPU
(8540) Tune for CPU
Operating System下的配置
Path to custom tarball : /opt/powerpc/crosstool-ng-1.9.3/dl/linux-2.6.28.10.tar.bz2
C-library下的配置
Configuration file : /opt/powerpc/crosstool-ng-1.9.3/ppc_e500_uClibc-0.9.30.1.config
8.编译
[root@localhost crosstool-ng-1.9.3]# ./ct-ng build
[INFO ] Performing some trivial sanity checks
[INFO ] Build started 20110801.154515
[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 = powerpc-unknown-linux-uclibc
[EXTRA] Dumping internal crosstool-NG configuration: done in 0.16s (at 00:03)
[INFO ] =================================================================
[INFO ] Retrieving needed toolchain components‘ tarballs
[EXTRA] Retrieving ‘expat-2.0.1‘
[EXTRA] Saving ‘expat-2.0.1.tar.gz‘ to local storage
[INFO ] Retrieving needed toolchain components‘ tarballs: done in 6.81s (at 00:10)
[INFO ] =================================================================
[INFO ] Extracting and patching toolchain components
[EXTRA] Extracting custom linux kernel
[EXTRA] Extracting ‘binutils-2.19.1‘
[EXTRA] Patching ‘binutils-2.19.1‘
[EXTRA] Extracting ‘gcc-4.2.4‘
[EXTRA] Patching ‘gcc-4.2.4‘
[EXTRA] Extracting ‘uClibc-0.9.30.1‘
[EXTRA] Patching ‘uClibc-0.9.30.1‘
[EXTRA] Extracting ‘dmalloc-5.5.2‘
[EXTRA] Patching ‘dmalloc-5.5.2‘
[EXTRA] Extracting ‘duma_2_5_15‘
[EXTRA] Patching ‘duma-2_5_15‘
[EXTRA] Extracting ‘gdb-6.8‘
[EXTRA] Patching ‘gdb-6.8‘
[EXTRA] Extracting ‘ncurses-5.7‘
[EXTRA] Patching ‘ncurses-5.7‘
[EXTRA] Extracting ‘expat-2.0.1‘
[EXTRA] Patching ‘expat-2.0.1‘
[EXTRA] Extracting ‘strace-4.5.18‘
[EXTRA] Patching ‘strace-4.5.18‘
[INFO ] Extracting and patching toolchain components: done in 154.12s (at 02:44)
[INFO ] =================================================================
[INFO ] Checking C library configuration
[EXTRA] Munging uClibc configuration
[INFO ] Checking C library configuration: done in 0.26s (at 02:44)
[INFO ] =================================================================
[INFO ] Installing kernel headers
[EXTRA] Installing kernel headers
[INFO ] Installing kernel headers: done in 18.47s (at 03:03)
[INFO ] =================================================================
[INFO ] Installing binutils
[EXTRA] Configuring binutils
[EXTRA] Building binutils
[INFO ] Installing binutils: done in 155.41s (at 05:38)
[INFO ] =================================================================
[INFO ] Installing C library headers
[EXTRA] Copying sources to build dir
[EXTRA] Applying configuration
[EXTRA] Building headers
[EXTRA] Installing headers
[INFO ] Installing C library headers: done in 14.44s (at 05:53)
[INFO ] =================================================================
[INFO ] Installing static core C compiler
[EXTRA] Configuring static core C compiler
[EXTRA] Building static core C compiler
[EXTRA] Installing static core C compiler
[INFO ] Installing static core C compiler: done in 261.93s (at 10:15)
[INFO ] =================================================================
[INFO ] Installing C library
[EXTRA] Copying sources to build dir
[EXTRA] Applying configuration
[EXTRA] Building C library
[EXTRA] Installing C library
[INFO ] Installing C library: done in 124.42s (at 12:19)
[INFO ] =================================================================
[INFO ] Installing final compiler
[EXTRA] Configuring final compiler
[EXTRA] Building final compiler
[EXTRA] Installing final compiler
[INFO ] Installing final compiler: done in 206.61s (at 15:46)
[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 161.86s (at 18:28)
[INFO ] =================================================================
[INFO ] Installing dmalloc
[EXTRA] Configuring dmalloc
[EXTRA] Building dmalloc
[EXTRA] Installing dmalloc
[INFO ] Installing dmalloc: done in 15.66s (at 18:43)
[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 1.99s (at 18:45)
[INFO ] =================================================================
[INFO ] Installing cross-gdb
[EXTRA] Configuring cross-gdb
[EXTRA] Building cross-gdb
[EXTRA] Installing cross-gdb
[INFO ] Installing cross-gdb: done in 340.12s (at 24:25)
[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 439.59s (at 31:45)
[INFO ] =================================================================
[INFO ] Installing gdbserver
[EXTRA] Configuring gdbserver
[EXTRA] Building gdbserver
[EXTRA] Installing gdbserver
[INFO ] Installing gdbserver: done in 15.48s (at 32:01)
[INFO ] =================================================================
[INFO ] Installing strace
[EXTRA] Configuring strace
[EXTRA] Building strace
[EXTRA] Installing strace
[INFO ] Installing strace: done in 24.32s (at 32:25)
[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
[EXTRA] Removing installed documentation
[INFO ] Cleaning-up the toolchain‘s directory: done in 2.28s (at 32:27)
[INFO ] Build completed at 20110801.161742
[INFO ] (elapsed: 32:27.21)
[INFO ] Finishing installation (may take a few seconds)...
[32:27] / [root@localhost crosstool-ng-1.9.3]#
9.
进入x-tools/powerpc-unknown-linux-uclibc/
创建link.sh脚本文件,然后执行该脚本
####link.sh####
#!/bin/sh
DEFAULT_PREFIX=powerpc-unknown-linux-uclibc-
CROSS_PREFIX=powerpc-linux-
BINUTILS="addr2line ar as c++ c++filt cc cpp ct-ng.config embedspu \
g++ gcc gcc-4.2.4 gccbug gcov gdb gdbtui gfortran gprof \
ld ldd nm objcopy objdump populate ranlib readelf run size \
strings strip"
#BINUTILS="addr2line ar"
echo create dir link
ln -s powerpc-unknown-linux-uclibc powerpc-linux
cd bin/
for i in $BINUTILS
do
src_name=$DEFAULT_PREFIX$i
des_name=$CROSS_PREFIX$i
/bin/rm -f $des_name
echo create soft link: $des_name link to $src_name
ln -s $src_name $des_name
done
#######
10.打包交叉编译工具链
进入x-tools/powerpc-unknown-linux-uclibc/
tar -cjvf powerpc-unknown-linux-uclibc.tar.bz2 powerpc-unknown-linux-uclibc/
11.错误记录
[INFO ] =================================================================
[INFO ] Installing static core C compiler
[EXTRA] Configuring static core C compiler
[ERROR] configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.0+.
[ERROR] Build failed in step ‘Installing static core C compiler‘
[ERROR] Error happened in ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/functions‘ in function ‘CT_DoExecLog‘ (line unknown, sorry)
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/build/cc/gcc.sh‘ at line # 203 in function ‘do_cc_core‘
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/build/cc/gcc.sh‘ at line # 74 in function ‘do_cc_core_pass_2‘
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/crosstool-NG.sh‘ at line # 597 in function ‘main‘
[ERROR] Look at ‘/root/x-tools/powerpc-unknown-linux-uclibc/build.log‘ for more info on this error.
[ERROR] (elapsed: 6:39.85)
[06:40] / make: *** [build] Error 1
[INFO ] Installing static core C compiler
[EXTRA] Configuring static core C compiler
[EXTRA] Building static core C compiler
[ERROR] make[1]: *** [configure-gcc] Error 1
[ERROR] Build failed in step ‘Installing static core C compiler‘
[ERROR] Error happened in ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/functions‘ in function ‘CT_DoExecLog‘ (line unknown, sorry)
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/build/cc/gcc.sh‘ at line # 289 in function ‘do_cc_core‘
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/build/cc/gcc.sh‘ at line # 76 in function ‘do_cc_core_pass_2‘
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/crosstool-NG.sh‘ at line # 597 in function ‘main‘
[ERROR] Look at ‘/root/x-tools/powerpc-unknown-linux-uclibc/build.log‘ for more info on this error.
[ERROR] (elapsed: 3:41.27)
[03:42] / make: *** [build] Error 2
[DEBUG] ==> Executing: ‘autoreconf‘
[ALL ] configure.in:27: require Automake 1.10.1, but have 1.10
[ALL ] autoreconf: automake failed with exit status: 1
[ERROR] Build failed in step ‘Extracting and patching toolchain components‘
[ERROR] Error happened in ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/functions‘ in function ‘CT_DoExecLog‘ (line unknown, sorry)
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/build/companion_libs/mpfr.sh‘ at line # 36 in function ‘do_mpfr_extract‘
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/crosstool-NG.sh‘ at line # 559 in function ‘main‘
[ERROR] Look at ‘/opt/powerpc/crosstool-ng-1.9.3/x-tools/powerpc-unknown-linux-uclibc/build.log‘ for more info on this error.
[ERROR] (elapsed: 1:20.97)
[INFO ] =================================================================
[INFO ] Installing final compiler
[EXTRA] Configuring final compiler
[EXTRA] Building final compiler
[ERROR] checking for suffix of object files... configure: error: cannot compute suffix of object files: cannot compile
[ERROR] make[2]: *** [configure-target-libstdc++-v3] Error 1
[ERROR] make[1]: *** [all] Error 2
[ERROR] Build failed in step ‘Installing final compiler‘
[ERROR] Error happened in ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/functions‘ in function ‘CT_DoExecLog‘ (line unknown, sorry)
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/build/cc/gcc.sh‘ at line # 470 in function ‘do_cc‘
[ERROR] called from ‘/opt/powerpc/install_dir//lib/ct-ng-1.9.3/scripts/crosstool-NG.sh‘ at line # 597 in function ‘main‘
[ERROR] Look at ‘/opt/powerpc/crosstool-ng-1.9.3/x-tools/powerpc-unknown-linux-uclibc/build.log‘ for more info on this error.
[ERROR] (elapsed: 22:48.43)
[22:49] / make: *** [build] Error 2
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。