Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 2764|回复: 0

Android平台下FreePascal的交叉编译

[复制链接]

该用户从未签到

发表于 2011-10-25 10:30:01 | 显示全部楼层 |阅读模式
背景: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/pr ... mpiler-for-android/  
2) http://wiki.freepascal.org/Android_Interface
3) http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM  
4)http://blog.huxuan.org/corsscomp ... -pascal-on-android/
回复

使用道具 举报

*滑块验证:

本版积分规则

QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

GMT+8, 2026-6-21 18:18 , Processed in 0.031701 second(s), 10 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表