Android平臺下FreePascal的交叉編譯

背景:1:我筆記本是XP(Intel處理器),虛擬機中裝Ubuntu 10

  2.fpc是2.4.2 lazarus版本是0.9.30 Sourcery G++ Lite 2010-09  java jdk 1.6 android  的模擬器 2.2

步驟:

  1.安裝好fpc編譯器和lazarus  這一步略

  2.下載fpc-source ,鏈接如下:The ‘fpc-2.4.2.source.tar.gz’ onhttp://sourceforge.net/projects/freepascal/files/Source/2.4.2/

    2.1 解壓縮即可,我放在home/hotcyy/ 下,即絕對路徑爲home/hotcyy/fpc-source

  3.下載Sourcery G++ Lite,鏈接:The ‘IA32 GNU/Linux Installer’ onhttp://www.codesourcery.com/sgpp/lite/arm/portal/release1600

    3.1 在終端執行:sudo dpkg-reconfigure -plow dash,接着選擇No,繼續

    3.2 到軟件包的文件目錄 執行:chmod +x arm-2010.09-05-arm-none-linux-gnueabi.bin

    3.3 安裝:./arm-2010.09-05-arm-none-linux-gnueabi.bin  我這邊的路徑爲:/home/hotcyy/CodeSourcery/Sourcery_G++_Lite

    3.4 安裝好之後一定要檢查環境變量,即驗證是否安裝成功。在終端運行arm-none-linux-gnueabi-gcc -v 若顯示版本則證明安裝成功了,若不成功,這需要添加環境變量:export PATH=$HOME/hotcyy/CodeSourcery/Sourcery_G++_Lite/bin,或直接用vim編輯環境變量。

  4 去fpc-source的目錄下,請先確認fpc-source/rtl/units/arm-linux文件下存有*.ppu;*.o文件等存在證明沒問題了 可進行下一步

  執行:make crossall CPU_TARGET=arm OS_TARGET=linux OPT="-dFPC_ARMEL -O- -gl"  CROSSPORT="-O-" CROSSBINDIR=/home/hotcyy/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/bin 

  5.便在/home/hotcyy/fpc-source/compilers/目錄下生成了 ppcrossarm文件

  6.編寫一個簡單的Helloworld的pascal程序 略

  7 到/home/hotcyy/fpc-source/compilers/此目錄下:執行 ./ppcrossarm -Tlinux -O- -XP -Fu/home/hotcyy/fpc-source/rtl/units/arm-linux/ -FD/home/hotcyy/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/bin /home/hotcyy/dev/hello.pas

  Note: -Fu is the unit path, -FD is the compiler utilities path.

  8.便在hello.pas目錄下頁生成hello和hello.o兩個文件

  9.裝好android的環境之後,啓動模擬器,執行:./adb push /home/hotcyy/dev/hello /data/hello  (注意前面是源文件路徑,後者路徑必須是data/*)

  10. 繼而執行:./adb shell  /data/hello 便在終端中看到了Hello World   -----------------The END



Reference:

  1) http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/

  2) http://wiki.freepascal.org/Android_Interface

  3) http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM

  4)http://blog.huxuan.org/corsscompiler-to-run-free-pascal-on-android/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章