Ubuntu9.10制作ARM交叉編譯器
準備軟件包如下:
bison_13a2.3.dfsg-4build1_i386.deb
build-essential_11.4_i386.deb
flex_2.5.33-10build1_i386.deb
libncurses5-dev_5.6+20071124-1ubuntu2_i386.deb
m4_1.4.8-1build1_i386.deb
patch_2.5.9-5_i386.deb
gcc-3.4.5.tar.gz
glibc-2.3.6.tar.gz
linux-2.6.26.5.tar.gz
crosstool-0.43.tar.gz
binutils-2.15.tar.gz
glibc-linuxthreads-2.3.3.tar.gz
linux-libc-headers-2.6.12.0.tar.bz2
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i m4_1.4.8-1build1_i386.deb
[sudo] password for furtherchan:
Selecting previously deselected package m4.
(Reading database ... 191676 files and directories currently installed.)
Unpacking m4 (from m4_1.4.8-1build1_i386.deb) ...
Setting up m4 (1.4.8-1build1) ...
Ignoring install-info called from maintainer script
The package m4 should be rebuild with new debhelper to get trigger support
Processing triggers for install-info ...
Processing triggers for man-db ...
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i bison_13a2.3.dfsg-4build1_i386.deb
Selecting previously deselected package bison.
(Reading database ... 191725 files and directories currently installed.)
Unpacking bison (from bison_13a2.3.dfsg-4build1_i386.deb) ...
Setting up bison (1:2.3.dfsg-4build1) ...
update-alternatives: using /usr/bin/bison.yacc to provide /usr/bin/yacc (yacc) in auto mode.
Processing triggers for man-db ...
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i build-essential_11.4_i386.deb
(Reading database ... 191752 files and directories currently installed.)
Preparing to replace build-essential 11.4 (using build-essential_11.4_i386.deb) ...
Unpacking replacement build-essential ...
Setting up build-essential (11.4) ...
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i flex_2.5.33-10build1_i386.deb
Selecting previously deselected package flex.
(Reading database ... 191752 files and directories currently installed.)
Unpacking flex (from flex_2.5.33-10build1_i386.deb) ...
Setting up flex (2.5.33-10build1) ...
Ignoring install-info called from maintainer script
The package flex should be rebuild with new debhelper to get trigger support
Ignoring install-info called from maintainer script
The package flex should be rebuild with new debhelper to get trigger support
Processing triggers for install-info ...
Processing triggers for man-db ...
^[[Afurtherchan@ubuntu910:~/Downloads$sudo dpkg -i patch_2.5.9-5_i386.deb
(Reading database ... 191775 files and directories currently installed.)
Preparing to replace patch 2.5.9-5 (using patch_2.5.9-5_i386.deb) ...
Unpacking replacement patch ...
Setting up patch (2.5.9-5) ...
Processing triggers for man-db ...
furtherchan@ubuntu910:~/Downloads$sudo dpkg –i libncurses5-dev_5.6+20071124-1ubuntu2_i386.deb
Selecting previously deselected package libncurses5-dev.
(Reading database ... 191775 files and directories currently installed.)
Unpacking libncurses5-dev (from libncurses5-dev_5.6+20071124-1ubuntu2_i386.deb) ...
dpkg: dependency problems prevent configuration of libncurses5-dev:
libncurses5-dev depends on libncurses5 (= 5.6+20071124-1ubuntu2); however:
Version of libncurses5 on system is 5.7+20090803-2ubuntu2.
#注釋:出錯,libncurses5在9.10上是5.7+20090803-2ubuntu2,不影響下面,暫且跳過
dpkg: error processing libncurses5-dev (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db ...
Errors were encountered while processing:
libncurses5-dev
furtherchan@ubuntu910:~/Downloads$
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i gcc-4.1_4.1.2-23ubuntu3_i386.deb
(Reading database ... 192865 files and directories currently installed.)
Preparing to replace gcc-4.1 4.1.2-23ubuntu3 (using gcc-4.1_4.1.2-23ubuntu3_i386.deb) ...
Unpacking replacement gcc-4.1 ...
Setting up gcc-4.1 (4.1.2-23ubuntu3) ...
Processing triggers for man-db ...
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i gcc-4.1-base_4.1.2-23ubuntu3_i386.deb
(Reading database ... 192865 files and directories currently installed.)
Preparing to replace gcc-4.1-base 4.1.2-23ubuntu3 (using gcc-4.1-base_4.1.2-23ubuntu3_i386.deb) ...
Unpacking replacement gcc-4.1-base ...
Setting up gcc-4.1-base (4.1.2-23ubuntu3) ...
furtherchan@ubuntu910:~/Downloads$sudo dpkg -i cpp-4.1_4.1.2-23ubuntu3_i386.deb
(Reading database ... 192865 files and directories currently installed.)
Preparing to replace cpp-4.1 4.1.2-23ubuntu3 (using cpp-4.1_4.1.2-23ubuntu3_i386.deb) ...
Unpacking replacement cpp-4.1 ...
Setting up cpp-4.1 (4.1.2-23ubuntu3) ...
Processing triggers for man-db ...
furtherchan@ubuntu910:~/Downloads$
furtherchan@ubuntu910:/usr/bin$ ls -l gcc
lrwxrwxrwx 1 root root 7 2009-11-16 21:27 gcc -> gcc-4.4
furtherchan@ubuntu910:/usr/bin$ mv gcc gcc_bck
mv: cannot move `gcc to `gcc_bck: Permission denied
furtherchan@ubuntu910:/usr/bin$sudo mv gcc gcc_bck
furtherchan@ubuntu910:/usr/bin$ ls -l gcc_bck
lrwxrwxrwx 1 root root 7 2009-11-16 21:27 gcc_bck -> gcc-4.4
furtherchan@ubuntu910:/usr/bin$ ls -l /usr/bin/gcc-4.1
-rwxr-xr-x 1 root root 198916 2008-10-26 21:12 /usr/bin/gcc-4.1
furtherchan@ubuntu910:/usr/bin$sudo ln -s /usr/bin/gcc-4.1 /usr/bin/gcc
#注釋:修改gcc鏈接,鏈接至4.1版本
furtherchan@ubuntu910:/usr/bin$ ls -l gcc
lrwxrwxrwx 1 root root 16 2010-05-19 14:57 gcc -> /usr/bin/gcc-4.1
furtherchan@ubuntu910:/usr/bin$
furtherchan@ubuntu910:/usr/bin$ ls -la /bin/sh
lrwxrwxrwx 1 root root 4 2009-11-16 21:27/bin/sh -> dash
furtherchan@ubuntu910:/usr/bin$sudo dpkg-reconfigure dash
#注釋:在配置界面上選擇NO刪除dash
Removing `diversion of /bin/sh to /bin/sh.distrib by dash
Removing `diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash
furtherchan@ubuntu910:/usr/bin$
furtherchan@ubuntu910:~/Downloads$tar -zxvf crosstool-0.43.tar.gz
furtherchan@ubuntu910:~/Downloads$ cd crosstool-0.43/
furtherchan@ubuntu910:~/Downloads/crosstool-0.43$gedit demo-arm-softfloat.sh
#注釋:修改路徑
#set -ex
#TARBALLS_DIR=/home/furtherchan/Downloads
#RESULT_TOP=/home/furtherchan/Crosstool
furtherchan@ubuntu910:~/Downloads/crosstool-0.43$gedit gcc-3.4.5-glibc-2.3.6.dat
#注釋:修改名稱
# BINUTILS_DIR=binutils-2.15
# GCC_DIR=gcc-3.4.5
# GLIBC_DIR=glibc-2.3.6
# LINUX_DIR=linux-2.6.26.5
# LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.12.0
# GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.6
furtherchan@ubuntu910:~/Downloads/crosstool-0.43$./demo-arm-softfloat.sh
#注釋:執(zhí)行2分鐘左右出錯,報too old ld,ld版本不對,查看版本:
furtherchan@ubuntu910:~/Downloads/crosstool-0.43$ld -v
GNU ld (GNU Binutils for Ubuntu) 2.20
#注釋:
#解決:解壓glibc-2.3.6.tar.bz2,修改glibc-2.3.6下的configure,修改完重新打包壓縮成tar.bz2
#####################################################################
# Found it, now check the version.
echo "$as_me:$LINENO: checking version of $AS" >&5
echo $ECHO_N "checking version of $AS... $ECHO_C" >&6
ac_prog_version=`$AS -v &1 | sed -n s/^.*GNU assembler.* /([0-9]*/.[0-9.]*/).*$//1/p`
case $ac_prog_version in
) ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2.2[0-9]*)<--------------line: 3920,修改版本范圍,還有下一處
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
# Found it, now check the version.
echo "$as_me:$LINENO: checking version of $LD" >&5
echo $ECHO_N "checking version of $LD... $ECHO_C" >&6
ac_prog_version=`$LD --version 2>&1 | sed -n s/^.*GNU ld.* /([0-9][0-9]*/.[0-9.]*/).*$//1/p`
case $ac_prog_version in
) ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
2.2[0-9]*)<--------------line: 3981,修改版本范圍
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
重新運行./demo-arm-softfloat.sh
######################################################################
#注釋:以下省略N行
…….
…….
…….
+ test -f /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/lib/libmudflap.so.?
+ for DIR in $PREFIX/$TARGET/lib $PREFIX/$TARGET/lib64
+ test -f /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/lib64/libmudflap.so
+ test -f /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/lib64/libmudflap.so.?
+ cd /home/furtherchan/Downloads/crosstool-0.43
+ gcc fix-embedded-paths.c -o /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/fix-embedded-paths
fix-embedded-paths.c: In function ‘testit’:
fix-embedded-paths.c:368: warning: initializer element is not constant
fix-embedded-paths.c:368: warning: (near initialization for ‘all_tests[2]’)
+ echo Cross-toolchain build complete. Result in /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu.
Cross-toolchain build complete. Result in /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu.
+ exit 0
+ cd /home/furtherchan/Downloads/crosstool-0.43
+ sh testhello.sh
+ cd /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu
+ test ! -d tmp
+ mkdir tmp
+ cd tmp
+ test x != x
+ cat
+ /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc -static hello.c -o arm-softfloat-linux-gnu-hello-static
+ /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc hello.c -o arm-softfloat-linux-gnu-hello
+ test -x /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-g++
+ cat
+ /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-g++ -static hello2.cc -o arm-softfloat-linux-gnu-hello2-static
+ /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-g++ hello2.cc -o arm-softfloat-linux-gnu-hello2
+ echo testhello: C compiler can in fact build a trivial program.
testhello: C compiler can in fact build a trivial program.
+ test = 1
+ test = 1
+ test = 1
+ test 1 =
+ echo Done.
Done.
#注釋:編譯完成
furtherchan@ubuntu910:~/Downloads/crosstool-G9ho
#注釋:接下來加入環(huán)境變量
#修改/etc/bash.bashrc
export PATH=$PATH:/home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin:
furtherchan@ubuntu910:~/Crosstool$ ls
gcc-3.4.5-glibc-2.3.6gcc-3.4.5-glibc-2.3.6.tar.bz2
furtherchan@ubuntu910:~/Crosstool$ cd gcc-3.4.5-glibc-2.3.6/
furtherchan@ubuntu910:~/Crosstool/gcc-3.4.5-glibc-2.3.6$ ls
arm-softfloat-linux-gnu
furtherchan@ubuntu910:~/Crosstool/gcc-3.4.5-glibc-2.3.6$ cd arm-softfloat-linux-gnu/
furtherchan@ubuntu910:~/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu$ ls
arm-softfloat-linux-gnubinincludelibman
arm-softfloat-linux-gnu.crosstoolconfig.txtdistributedinfolibexectmp
furtherchan@ubuntu910:~/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu$ cd bin
furtherchan@ubuntu910:~/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin$ ls
arm-softfloat-linux-gnu-addr2linearm-softfloat-linux-gnu-gprof
arm-softfloat-linux-gnu-ararm-softfloat-linux-gnu-ld
arm-softfloat-linux-gnu-asarm-softfloat-linux-gnu-nm
arm-softfloat-linux-gnu-c++arm-softfloat-linux-gnu-objcopy
arm-softfloat-linux-gnu-c++filtarm-softfloat-linux-gnu-objdump
arm-softfloat-linux-gnu-cpparm-softfloat-linux-gnu-ranlib
arm-softfloat-linux-gnu-g++arm-softfloat-linux-gnu-readelf
arm-softfloat-linux-gnu-gccarm-softfloat-linux-gnu-size
arm-softfloat-linux-gnu-gcc-3.4.5arm-softfloat-linux-gnu-strings
arm-softfloat-linux-gnu-gccbugarm-softfloat-linux-gnu-strip
arm-softfloat-linux-gnu-gcovfix-embedded-paths
furtherchan@ubuntu910:~/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin$
furtherchan@ubuntu910:~/c/test$arm-softfloat-linux-gnu-gcc -v
Reading specs from /home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/lib/gcc/arm-softfloat-linux-gnu/3.4.5/specs
Configured with: /home/furtherchan/Downloads/crosstool-0.43/build/arm-softfloat-linux-gnu/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure --target=arm-softfloat-linux-gnu --host=i686-host_pc-linux-gnu --prefix=/home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu --with-float=soft --with-headers=/home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/include --with-local-prefix=/home/furtherchan/Crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.5
furtherchan@ubuntu910:~/c/test$
furtherchan@ubuntu910:~/c/test$arm-softfloat-linux-gnu-gcc -o test test.c
furtherchan@ubuntu910:~/c/test$file test
test: ELF 32-bit LSB executable,ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped
#注釋:文件格式已是ARM
furtherchan@ubuntu910:~/c/test$
評論