部署交叉编译工具链

一. 安装arm-2009q3

  1.1. 在虚拟机创建安装文件夹

    1.1.1. 在/usr/local/下创建/usr/local/arm文件夹

    1.1.2. 将arm-2009q3.tar.bz2放到相关文件夹

    1.1.3. 解压压缩包

      a. tar -jxvf arm-2009q3.tar.bz2

root@ubuntu:/usr/local/arm# ls
arm-2009q3  arm-2009q3.tar.bz2
root@ubuntu:/usr/local/arm# 

  1.2. 测试交叉编译工具链

    1.2.1. ./arm-none-linux-gnueabi-gcc -v

root@ubuntu:/usr/local/arm# cd arm-2009q3
root@ubuntu:/usr/local/arm/arm-2009q3# cd bin/
root@ubuntu:/usr/local/arm/arm-2009q3/bin# ./arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/2009q3-respin-linux-lite/src/gcc-4.4/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --disable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q3-67' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/2009q3-respin-linux-lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2009q3-respin-linux-lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/2009q3-respin-linux-lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) 
root@ubuntu:/usr/local/arm/arm-2009q3/bin# 
View Code

二. 添加交叉编译工具链到环境变量中

  2.1. 环境变量的意义

    2.1.1. 环境变量就是操作系统的全局变量。每一个环境变量对操作系统来说都是唯一的,名字和所代表的意义都是唯一的。linux系统可以有很多个环境变量。其中有一部分是linux系统自带的,还有一些是我们自己来扩充的。我们这里涉及到的一个环境变量是

PATH。PATH这个环境变量是系统自带的,它的含义就是系统在查找可执行程序时会搜索的路径范围。

  2.2. 将工具链导出到环境变量

    2.1.1. 导入环境变量

      a. export PATH=/usr/local/arm/arm-2009q3/bin:$PATH

    2.1.2. 查看导入后的环境变量

root@ubuntu:/usr/local/arm/arm-2009q3/bin# echo $PATH
/usr/local/arm/arm-2009q3/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
root@ubuntu:/usr/local/arm/arm-2009q3/bin#

  2.3. 实现打开终端就执行导入

    2.3.1. 在~/.bashrc中,添加export PATH=/usr/local/arm/arm-2009q3/bin:$PATH 即可

 

三. 工具链创建arm-linux-xxx符号链接

  3.1. 使用脚本来创建

ln arm-none-linux-gnueabi-addr2line -s arm-linux-addr2line
ln arm-none-linux-gnueabi-ar -s arm-linux-ar
ln arm-none-linux-gnueabi-as -s arm-linux-as
ln arm-none-linux-gnueabi-c++ -s arm-linux-c++
ln arm-none-linux-gnueabi-c++filt -s arm-linux-c++filt
ln arm-none-linux-gnueabi-cpp -s arm-linux-cpp
ln arm-none-linux-gnueabi-g++ -s arm-linux-g++
ln arm-none-linux-gnueabi-gcc -s arm-linux-gcc
ln arm-none-linux-gnueabi-gcc-4.4.1 -s arm-linux-gcc-4.4.1
ln arm-none-linux-gnueabi-gcov -s arm-linux-gcov
ln arm-none-linux-gnueabi-gdb -s arm-linux-gdb
ln arm-none-linux-gnueabi-gdbtui -s arm-linux-gdbtui
ln arm-none-linux-gnueabi-gprof -s arm-linux-gprof
ln arm-none-linux-gnueabi-ld -s arm-linux-ld
ln arm-none-linux-gnueabi-nm -s arm-linux-nm
ln arm-none-linux-gnueabi-objcopy -s arm-linux-objcopy
ln arm-none-linux-gnueabi-objdump -s arm-linux-objdump
ln arm-none-linux-gnueabi-ranlib -s arm-linux-ranlib
ln arm-none-linux-gnueabi-readelf -s arm-linux-readelf
ln arm-none-linux-gnueabi-size -s arm-linux-size
ln arm-none-linux-gnueabi-sprite -s arm-linux-sprite
ln arm-none-linux-gnueabi-strings -s arm-linux-strings
ln arm-none-linux-gnueabi-strip -s arm-linux-strip
View Code

  3.2. 创建后效果

root@ubuntu:/usr/local/arm/arm-2009q3/bin# ls -l
total 15744
lrwxrwxrwx 1 root root      32 Sep  9 08:01 arm-linux-addr2line -> arm-none-linux-gnueabi-addr2line
lrwxrwxrwx 1 root root      25 Sep  9 08:01 arm-linux-ar -> arm-none-linux-gnueabi-ar
lrwxrwxrwx 1 root root      25 Sep  9 08:01 arm-linux-as -> arm-none-linux-gnueabi-as
lrwxrwxrwx 1 root root      26 Sep  9 08:01 arm-linux-c++ -> arm-none-linux-gnueabi-c++
lrwxrwxrwx 1 root root      30 Sep  9 08:01 arm-linux-c++filt -> arm-none-linux-gnueabi-c++filt
lrwxrwxrwx 1 root root      26 Sep  9 08:01 arm-linux-cpp -> arm-none-linux-gnueabi-cpp
lrwxrwxrwx 1 root root      26 Sep  9 08:01 arm-linux-g++ -> arm-none-linux-gnueabi-g++
lrwxrwxrwx 1 root root      26 Sep  9 08:01 arm-linux-gcc -> arm-none-linux-gnueabi-gcc
lrwxrwxrwx 1 root root      32 Sep  9 08:01 arm-linux-gcc-4.4.1 -> arm-none-linux-gnueabi-gcc-4.4.1
lrwxrwxrwx 1 root root      27 Sep  9 08:01 arm-linux-gcov -> arm-none-linux-gnueabi-gcov
lrwxrwxrwx 1 root root      26 Sep  9 08:01 arm-linux-gdb -> arm-none-linux-gnueabi-gdb
lrwxrwxrwx 1 root root      29 Sep  9 08:01 arm-linux-gdbtui -> arm-none-linux-gnueabi-gdbtui
lrwxrwxrwx 1 root root      28 Sep  9 08:01 arm-linux-gprof -> arm-none-linux-gnueabi-gprof
lrwxrwxrwx 1 root root      25 Sep  9 08:01 arm-linux-ld -> arm-none-linux-gnueabi-ld
lrwxrwxrwx 1 root root      25 Sep  9 08:01 arm-linux-nm -> arm-none-linux-gnueabi-nm
lrwxrwxrwx 1 root root      30 Sep  9 08:01 arm-linux-objcopy -> arm-none-linux-gnueabi-objcopy
lrwxrwxrwx 1 root root      30 Sep  9 08:01 arm-linux-objdump -> arm-none-linux-gnueabi-objdump
lrwxrwxrwx 1 root root      29 Sep  9 08:01 arm-linux-ranlib -> arm-none-linux-gnueabi-ranlib
lrwxrwxrwx 1 root root      30 Sep  9 08:01 arm-linux-readelf -> arm-none-linux-gnueabi-readelf
lrwxrwxrwx 1 root root      27 Sep  9 08:01 arm-linux-size -> arm-none-linux-gnueabi-size
lrwxrwxrwx 1 root root      29 Sep  9 08:01 arm-linux-sprite -> arm-none-linux-gnueabi-sprite
lrwxrwxrwx 1 root root      30 Sep  9 08:01 arm-linux-strings -> arm-none-linux-gnueabi-strings
lrwxrwxrwx 1 root root      28 Sep  9 08:01 arm-linux-strip -> arm-none-linux-gnueabi-strip
-rwxr-xr-x 1 root root  547548 Oct 16  2009 arm-none-linux-gnueabi-addr2line
-rwxr-xr-x 2 root root  572276 Oct 16  2009 arm-none-linux-gnueabi-ar
-rwxr-xr-x 2 root root  954556 Oct 16  2009 arm-none-linux-gnueabi-as
-rwxr-xr-x 2 root root  210380 Oct 16  2009 arm-none-linux-gnueabi-c++
-rwxr-xr-x 1 root root  547324 Oct 16  2009 arm-none-linux-gnueabi-c++filt
-rwxr-xr-x 1 root root  209228 Oct 16  2009 arm-none-linux-gnueabi-cpp
-rwxr-xr-x 2 root root  210380 Oct 16  2009 arm-none-linux-gnueabi-g++
-rwxr-xr-x 2 root root  207948 Oct 16  2009 arm-none-linux-gnueabi-gcc
-rwxr-xr-x 2 root root  207948 Oct 16  2009 arm-none-linux-gnueabi-gcc-4.4.1
-rwxr-xr-x 1 root root   26760 Oct 16  2009 arm-none-linux-gnueabi-gcov
-rwxr-xr-x 1 root root 2840960 Oct 16  2009 arm-none-linux-gnueabi-gdb
-rwxr-xr-x 1 root root 2840960 Oct 16  2009 arm-none-linux-gnueabi-gdbtui
-rwxr-xr-x 1 root root  607456 Oct 16  2009 arm-none-linux-gnueabi-gprof
-rwxr-xr-x 2 root root  959396 Oct 16  2009 arm-none-linux-gnueabi-ld
-rwxr-xr-x 2 root root  556092 Oct 16  2009 arm-none-linux-gnueabi-nm
-rwxr-xr-x 2 root root  705268 Oct 16  2009 arm-none-linux-gnueabi-objcopy
-rwxr-xr-x 2 root root  836092 Oct 16  2009 arm-none-linux-gnueabi-objdump
-rwxr-xr-x 2 root root  572308 Oct 16  2009 arm-none-linux-gnueabi-ranlib
-rwxr-xr-x 1 root root  307848 Oct 16  2009 arm-none-linux-gnueabi-readelf
-rwxr-xr-x 1 root root  551680 Oct 16  2009 arm-none-linux-gnueabi-size
-rwxr-xr-x 1 root root  342540 Oct 16  2009 arm-none-linux-gnueabi-sprite
-rwxr-xr-x 1 root root  547516 Oct 16  2009 arm-none-linux-gnueabi-strings
-rwxr-xr-x 2 root root  705268 Oct 16  2009 arm-none-linux-gnueabi-strip
-rwxr-xr-x 1 root root    1167 Sep  9 08:00 mk-arm-linux.sh
root@ubuntu:/usr/local/arm/arm-2009q3/bin# 
View Code

 

参考《朱老师.1.2ARM裸机课件》 

posted @ 2019-01-05 00:13  三七鸽  阅读(655)  评论(0编辑  收藏  举报