1. 程式人生 > >部署交叉編譯工具鏈

部署交叉編譯工具鏈

img libc libstdc unwind reads bss sin cer scratch

一. 安裝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裸機課件》

部署交叉編譯工具鏈