[Android] Building Free Pascal Compiler for Android
I think most of us heard about young mobile platform Android by Google.
Google recomend to use Java for developing applications for Android, but there nothing dificult to use gcc cross compiler to build applications on C or C++, in one of next post i will write how to build application/library on c/c++ using android toolchain.
So we can use Java or C/C++ but what should developers dothat prefer Pascal?
Today i will tell how to build Free Pascal Compiler that can build applications for android.
To build cross compiler we will need:
- Free Pascal Compiler (you can get it from http://freepascal.org/download.var)
- arm-eabi toolchain (android eabi will not work, we got error on linking) so we need download toolchain (you can get it from [there windows and linux versions] http://www.codesourcery.com/sgpp/lite/arm/portal/release644)
- Last Free Pascal Sources (get if ftom svn http://svn.freepascal.org/svn/fpc/trunk)
Thats all, install toolchain packages and we can build crosscompiler.
To build crosscompiler you need:
a) in terminal (cmd for Windows) go to root folder that contatin fpc sources from svn
b) and type:
make crossall CPU_TARGET=arm OS_TARGET=linux OPT=”-dFPC_ARMEL -O- -gl” CROSSPORT=”-O-” CROSSBINDIR=/home/dabeat/toolchain/arm-none-linux-gnueabi/arm-eabi/bin
Note: (CROSSBINDIR – this is full path to downloaded and installedtoolchain)
That should be enough, if everything ok in folder that contain fpc in folder compiler you will find ppcrossarm, this is our cross compiler.
Lets build simple application:
program Hello;
begin
WriteLn(‘Hello World’);
end.
to build in terminal (cmd for windows) go to folder that contain crosscompiler and type:
./ppcrossarm -Tlinux -O- -XP -Fu/home/dabeat/fpc/rtl/units/arm-linux/ -FD/home/dabeat/toolchain/arm-none-linux-gnueabi/arm-eabi/bin /home/dabeat/Hello.pp
Note: -FD key that say to crosscompiler path to toolchain
-Fu key that say to crosscompiler path to cross rlt
if there wasnt errors then lets test built application:
1) Run emulator (you can find it in sdk`s tools folder)
2) In tools folder you will also find tool adb use it too load application on emulator:
./adb push /home/dabeat/Hello data/Hello
3) Run loaded application:
./adb shell data/Hello
as result you will see:
Hello Word
Yep we got it
There left one problem application aint exit (only Ctrl + C helps)
P.S. I built cross compiler on Linux Ubuntu but I`m sure that if you will do on Windows the same steps you will have the same result.
Filed under: Programming
June 3rd, 2009 at 9:31 pm
Just noticed this post. I did the exact same thing about 9 months ago, had the same problem - app doesn’t exit.
Tried talking with guys in #fpc but never figured it out…
(btw reply through mail I just came here through Google)
September 26th, 2009 at 12:40 pm
…. i search a app from android…. a compíler to dalvik or another VM …. do you know anyone?
November 26th, 2009 at 10:01 pm
Anyone tried to do this on Windows please paste the command you execute. I get error makefile:135: *** Compiler .exe not found. Stop.