Android平台下FreePascal的交叉編譯

來源:互聯網
上載者:User

背景: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/

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.