Recent

Author Topic: Running Pascal applications in Android  (Read 56534 times)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #15 on: January 18, 2011, 03:39:24 pm »
To do this, I used:
Lazarus-0.9.31-29090-fpc-2.4.3-20110118-win32.exe
Lazarus-0.9.31-29090-fpc-2.4.3-20110118-cross-arm-wince-win32.exe

Yes, but that's a cross-compiler for Windows CE, not for Linux.

I am trying to make a pre-compile installer for x86-linux -> arm-linux, but no success at the moment.

You can always build your own cross-compiler. For me it wasn't that hard. I installed FPC 2.4.2, download fpctrunk from subversion and issued:

make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/felipe/Programas/fpctrunk/binutils OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr/

I used the instructions here: http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM

Quote
I am familiar with Linux.
I know that the programs must have execute permissions.
I was wondering how do I generate and execute the file, inside the Android.
And how can I create a package APK.
Thanks.

After you have built the project for arm-linux, you create the APK in the command line by doing:

cd turbopascal4android/android
ant debug

Then the APK file will be located in turbopascal4android/android/bin

You need to have ant installed for this to work, and also to have the android SDK installed. You need to change the Android SDK location in turbopascal4android/android/local.properties

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: Running Pascal applications in Android
« Reply #16 on: January 19, 2011, 09:25:11 am »
CodeTyphon is very easy setup of FPC/Lazarus cross compiler with 4 hosts and 16 targets (including arm linux).

•    4 CPU-Operating Systems Host Layers icon5 (Win32, Win64, Linux32, Linux64).
•    16 CPU-Operating Systems Target Layers. icon5
•    Win64 Layer has Dual Personality (Win64 and Win32).
•    Win32 Layer is Cross-Build Center with Cross Elements for:
      arm-Wince
      arm-Linux
      arm-Embedded  (freepascal only)
      arm-gba            (freepascal only)
      arm-nds            (freepascal only)
      i386-Win32
      i386-Linux
      i386-FreeBSD
      i386-Haiku         (freepascal only)
      x86_64-Win64
      x86_64-Linux
      x86_64-FreeBSD
      powerpc-Linux
      powerpc64-Linux  (freepascal only)
      sparc-Linux
      sparc-Solaris      (freepascal only)

http://www.pilotlogic.com/sitejoom/index.php?option=com_content&view=article&id=96&catid=68&Itemid=147
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7508
Re: Running Pascal applications in Android
« Reply #17 on: January 19, 2011, 11:37:29 am »
CodeTyphon is very easy setup of FPC/Lazarus cross compiler with 4 hosts and 16 targets (including arm linux).

Avra, I don't mind you doing a bit of CodeTyphon advertising when it is on-topic, but at least try to provide
some realworld information relating to the topic instead of simply copying the birds-eye view from their website.

You can think of :

- own experiences using codetyphon for various arm-linux targets. (does it really work?)
- binutils versions
- devices supported
- eabi versions supported
- floating point yes/no ?

etc
 
All I can seem to find is a general set of arm-linux binutils which sounds it is probably EABI 0, which is next to useless for modern devices.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #18 on: January 27, 2011, 04:12:13 pm »
I am trying to make a pre-compile installer for x86-linux -> arm-linux, but no success at the moment.

You can always build your own cross-compiler. For me it wasn't that hard. I installed FPC 2.4.2, download fpctrunk from subversion and issued:

make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/felipe/Programas/fpctrunk/binutils OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr/

I used the instructions here: http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM

Ok, I managed to build a cross-compiler, but haven't yet tested it much.

I have placed my cross-compiler here:

https://sourceforge.net/projects/p-tools/files/Free%20Pascal%20for%20ARM/

Here is an rpm with cross-arm-binutils:

http://rpm.pbone.net/index.php3/stat/4/idpl/14252825/dir/mandriva_2010/com/cross-arm-binutils-2.20.51.0.4-2mnb2.i586.rpm.html

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #19 on: February 06, 2011, 03:44:48 pm »
Ok, I managed to get instruction about how to install the FPC which I compiled:

http://wiki.lazarus.freepascal.org/Android_Interface#Using_the_pre-compiled_compiler

These instructions should set up a x86-linux -> arm-linux cross-compiled which is appropriate for use for Android.

brelstad

  • Newbie
  • Posts: 1
Re: Running Pascal applications in Android
« Reply #20 on: March 09, 2011, 11:32:50 pm »
Hi, Felipe, two friends and myself are in the process of converting from Delphi to Lazarus.
(Instead of Java/Android, we discovered your work with the Android interface.)

How will you handle bitmaps?

Will the bitmap be created in the Java GUI and then made accessible in Lazarus through pipes?

Or will it be possible to manipulate a TBitmap in Pascal and then copy it
through pipes to a "bitmap-view" in the Java GUI?


Thanks,
Bengt

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #21 on: March 10, 2011, 11:08:29 am »
I haven't yet come to that, but I think that the best solution is using a surface which is accessible from native code. There are some possibilities:

1> The Surface API for Android 2.3+ (maybe accessible with some tricks in previous versions?)
2> An OpenGL ES surface
3> Just put it through the pipes as you mentioned

I am more inclined towards option 2.

Contributions are of course very welcome.

nighthawk09

  • New Member
  • *
  • Posts: 15
Re: Running Pascal applications in Android
« Reply #22 on: April 06, 2011, 12:20:11 pm »
I've developed an application in fpc-mac. And now would like to port that to android.

I've started checking the sample of the turbochessclock4android, on my windows machine.
Done the following:
A. Downloaded the eclipse + ADT (android plug in for that)..
B. Installed the android emulation and sdk
C. downloaded the fpc-android sample file
D. Opened a new android project under the eclipse, and added all the java classes for that.
E. Tried running the android fpc example on the emulator.

It raises an error that it can not run the application.
(Probably due to the fact that I haven't even added the pascal compiled code for that).,

* What do I need to do in order to compile the pascal code?
* How is the compiled pascal objects connected to the java classes compiled files?
* What do I need to do in order to combine the compiled java classes and the pascal objects?

* To create the APK I just ran the application from eclipse using the run as "Android app" (using the ADT Plugin). Is there a way to set the eclipse environment and make the pascal code compiled there as part of a whole project for android?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #23 on: April 06, 2011, 01:24:17 pm »
I've answered some stuff in the mailling list on the thread [fpc-pascal] Compiling android example

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #24 on: April 06, 2011, 01:27:24 pm »
* What do I need to do in order to combine the compiled java classes and the pascal objects?

Nothing. In Lazarus opening Project->Build is enough. Free Pascal puts the executable into android/libs/armeabi

Then when you run ANT, it will put the Pascal program inside the APK package.

Quote
* To create the APK I just ran the application from eclipse using the run as "Android app" (using the ADT Plugin). Is there a way to set the eclipse environment and make the pascal code compiled there as part of a whole project for android?

If it works like ANT then you don't need to do anything. Just build the Pascal code before building the APK

bigdude

  • Newbie
  • Posts: 2
Re: Running Pascal applications in Android
« Reply #25 on: April 19, 2011, 06:54:40 pm »
Sorry for this NOOB ANT question.. I need help with a path/build issue. I have been trying to build the chessclock sample and ran into problems with ANT.

The Lazarus part went fine and the library is built, but when I try to do a debug build with ANT it fails (the mixed forward and backward slashes below are probably the problem, but how can they be fixed)

C:\android-chessclock\android>ant debug
Buildfile: C:\android-chessclock\android\build.xml
    [setup] Android SDK Tools Revision 10
    [setup] Project Target: Android 2.1-update1
--- OMITTED SUCCESSFUL STEPS
-resource-src:
     [echo] Generating R.java / Manifest.java from the resources...
 [aapt.exe] invalid resource directory name: C:\android-chessclock\android\res/drawable-hpdi
 [aapt.exe] invalid resource directory name: C:\android-chessclock\android\res/drawable-lpdi

BUILD FAILED
C:\Archivos de programa\Android\android-sdk\tools\ant\main_rules.xml:310: null returned: 1

Total time: 1 second
« Last Edit: April 19, 2011, 10:19:43 pm by bigdude »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #26 on: April 20, 2011, 10:38:15 am »
Go to C:\android-chessclock\android\ and open all files in this directory in a text editor, for example Notepad++ and search for the place of the wrong slash. It's not really much, one can quickly read all files.

bigdude

  • Newbie
  • Posts: 2
Re: Running Pascal applications in Android
« Reply #27 on: April 20, 2011, 09:02:59 pm »
I checked all of the files in that folder again and none of them have slashes faced that way. In fact the path to the android project base is not even present in any of those files.

I beleive the problem is the basedir that is being provided to the android scripts by ANT, but I do not know how to override that. It looks like the code base directory is being provided with backslashes and then the scripts are appending with forward slashes. It would probably work with either one, but it chokes on the mix..

Could it be that the ant rules in the version of the android SDK I am using (2.1 lvl 7) have issues on the windows platform ??

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Running Pascal applications in Android
« Reply #28 on: April 20, 2011, 10:02:18 pm »
Could it be that the ant rules in the version of the android SDK I am using (2.1 lvl 7) have issues on the windows platform ??

I have no idea ... everyone in my work uses Linux for Android development. But this is a very generic problem, you could try asking in other places too. I tried googling for it, but I couldn't find anything.

bgrimes

  • New member
  • *
  • Posts: 5
Re: Running Pascal applications in Android
« Reply #29 on: May 21, 2011, 08:03:59 am »
I was wandering through the android market the other day and found that there is already a pascal interpreter for the android platform!  I was really happy to see that it is already available.

I noticed though that it was already out for about a year already. There are some comments though that do not favor pascal as they are saying that it needs a little more work to be on the right level.