0) Preface
0.1) The Operating System is Ubuntu 10.10
0.2) All the softwares are the latest stable version by April 12, 2011

1) Download the Source of Free Pascal Compiler
The ‘fpc-2.4.2.source.tar.gz’ on

2) Install the fpc-source. Just extract it.
The root folder of fpc-source for me is ‘/home/victorhu/fpc-source’

3) Download the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
The ‘IA32 GNU/Linux Installer’ on

4) Install the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
The installation need the system shell to be bash not dash which is default for Ubuntu. So

Choose NO to make the bash as the system shell.
4.2) Goto the root folder of Arm-Eabi for me is ‘/home/victorhu/toolchain/’


5) Get the Cross Compiler
5.1) Goto the root folder of fpc-source

5.3) The ‘ppcrossarm’ under ‘/home/victorhu/fpc-source/compilers/’ is just what we want.
Note: CROSSBINDIR is depend on the folder of Arm-Eabi.

6) Write a Hello Word in Pascal
The path for me is /home/victorhu/hello.pas

7) Compile the Hello World in Pascal via CrossCompile Environment.
7.1) Goto the folder contains ‘ppcrossarm’

Note: -Fu is the unit path, -FD is the compiler utilities path.
7.3) The ‘hello’ under ‘/home/victorhu/temp’ is just the what we want (not hello.pas).

8) Test the Crosscompiled Hello World in Android Emulator
8.1) the tools under Android SDK or the ADT of Eclipse is where we can find it.
8.2) Goto the adb root folder under Android SDK .
It’s ‘platform-tools’ under the main root folder of Android SDK now while it’s ‘tools’ before.
8.3) Test whether is device is connected.

If it shows somthing like ‘Emulator-5544 device’ (for me), then it’s right.
8.4) Push the program into Android Emulator.

8.5) Run the program on the Android Emulator.

If it shows ‘Hello World!’ (the result of the original program), then everything is done now!

9) Reference

P.S.本文参与“第二届 Google 暑期大学生博客分享大赛 – 2011 Android 成长篇”,感谢大家支持

2 thoughts on “Android平台下FreePascal的交叉编译器”

  1. 还是看8懂。。。。溜去看ubuntu10.04那里看看。。。。。。不要Spam我啊!!!

Leave a Reply