一、安裝ARM-Linux-GCC工具鏈
只需要一句命令:
sudo apt-get install gcc-arm-linux-gnueabi
前提是你的Ubuntu系統版本是官網支持的最新的版本,若不是,請升級。執行以上命令即可。
二、使用工具鏈
注意!這里不能使用 gcc 命令來召喚它。它的名字是 arm-linux-gnueabi-gcc 。如果出現 Command Not Found,請關閉Terminal,再重新打開。再不行,就變成超級用戶,把它添加到 PATH 中。
Tips:查看安裝位置。
首先你要取得超級用戶權限(臨時取得權限可用命令:sudo -i)
root@ql-virtual-machine:~# locate arm-linux-gnueabi-gcc /usr/bin/arm-linux-gnueabi-gcc /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/share/man/man1/arm-linux-gnueabi-gcc-4.6.1.gz /usr/share/man/man1/arm-linux-gnueabi-gcc.1.gz
參考資料:
其一,來自Stackoverflow,關於在Ubuntu或者Window安裝ARM工具鏈的回答。
For ARM-Linux application development the preferable choice is a Linux Host(x86) machine with a ARM toolchain installed in it. In Ubuntu Desktop machine you can use the following command to install ARM toolchain:
翻譯:對於ARM-Linux應用開發,最好的選擇是安裝了ARM工具鏈的x86 Linux主機。在Ubuntu桌面電腦中,你可以使用下面的命令安裝ARM工具鏈。
apt-get install gcc-arm-linux-gnueabiAfter toolchain installation you can use the following command for cross compilation:
翻譯:安裝完工具鏈后,你要用下面的命令進行交叉編譯:
gcc-arm-linux-gnueabi-gcc -o hello hello.cUsing this toolchain you can cross-compile your C program using Standard C library without the need of startup code. Applications can be cross-compiled at your Host Linux(x86) platform and run on Target Linux(ARM) platform.
Windows version of ARM-Linux Toolchain is also available. You can get it from here.
Linaro Developers Wiki - an open organization focused on improving Linux on ARM, will be a good reference for your work.
翻譯:使用這個工具鏈,你可以用C標准庫來交叉編譯你的C程序,而無需startup code?你的程序可以在你的x86的Linux主機上交叉編譯然后直接運行在Linux(ARM)平台上。 ARM-Linux工具鏈的windows版本也是可用的,你可以從這里獲取。 Linaro Developers Wiki - 一個致力於改進ARM平台Linux的開發組織,這對於你的工作將會是個很好的參考。
其二,來自 askUbuntu,關於在Ubuntu上如何安裝ARM工具鏈的回答。
.....However, if you're looking for an ARM cross-compiler, there is one pre-packaged in Ubuntu, which may be easier to get running. It's in the
gcc-arm-linux-gnueabipackage - to install it:翻譯:但是,如果你正在尋找一個 ARM 平台的交叉編譯器,在Ubuntu中倒是有一個打包好的,它或許比較容易運行。它在 gcc-arm-linux-gnueabi 包中,你可以這樣安裝它:sudo apt-get install gcc-arm-linux-gnueabi
源鏈接:http://askubuntu.com/questions/65630/installing-gnu-arm-toolchain
其三,來自stackoverflow。關於如何使用及添加到PATH方法。
CodeSourcery convention is to use prefix
arm-none-linux-gnueabi-for all executables, notgcc-arm-linux-gnueabithat you mention. So, standard name for CodeSourcery gcc would bearm-none-linux-gnueabi-gcc.After you have installed CodeSourcery G++, you need to add CodeSourcery directory into your
PATH.Typically, I prefer to install CodeSourcery into directory like
/opt/arm-2010q1or something like that. If you don't know where you have installed it, you can find it usinglocate arm-none-linux-gnueabi-gcc, however you may need to force to update your locate db usingsudo updatedbbeforelocatewill work properly.After you have identified where your CodeSourcery is installed, add it your PATH by editing
~/.bashrclike this:PATH=/opt/arm-2010q1/bin:$PATHAlso, it is customary and very convenient to define
CROSS_COMPILE=arm-none-linux-gnueabi-in your
.bashrc, because withCROSS_COMPILEdefined, most tools will automatically use proper compiler for ARM compilation without you doing anything.
源鏈接:http://stackoverflow.com/questions/14180185/gcc-arm-linux-gnueabi-command-not-found
————————————進展——————————————
安裝交叉編譯器。另注:經實測,此編譯鏈不適合mini2440。只有官方光盤里的arm-liinux-gcc4.3編譯出的程序才能在mini2440上運行。
此編譯器編譯后的helloworld在mini2440上總是出現unexpected } 錯誤。
