Recent

Author Topic: Android - Lazarus for Dummies (like me).  (Read 25861 times)

almcneill

  • New Member
  • *
  • Posts: 34
Android - Lazarus for Dummies (like me).
« on: October 20, 2011, 12:43:31 am »
All,

Background of my experience:

I started a long time ago writing my own programs (since Delphi 1), started doing it because I could not reason with myself purchasing expensive programs, when I should be able to do it myself.  With that being said, I learned Delphi/Pascal through self teaching.  I was pleased when kylix came out, disappointed when it went away, very pleased when I came across Lazarus, especially since I had switched to linux shortly after windows 98.

Now, I have written quite a few programs for my own use (for linux), and consider myself to be able to hold my own when it comes to figuring things out.  But now I would like to be able to port a couple of those to my Toshiba Thrive.  I came across a couple of links  (lazarus wiki) that kind of explained how to write programs for Android, but the instructions are pretty vague (at least to me) on how to go about doing this.

Where I need help, if someone could walk me through how to set it up, I could easily write a "how-to"/"for-dummies" guide to post here for other people who might be having the same problem, I am not completely helpless.  Below is listed what I have done so far, and now I am stuck.

OS - opensuse 11.4 64 bit
Lazarus - 0.9.30.2RC1
FPC - 2.4.4 (with source as well)

I have downloaded the following:
android sdk (per lazarus wiki)
fpc-2.5.1.arm-linux.tar.gz (per lazarus wiki)

I have followed a couple of different lazarus wiki pages trying to accomplish this task with no success.  I would really appreciate any help on how I can integrate my downloads (if needed) into my current lazarus, so that I can attempt to start writing Android apps.  I am very anxious to start doing this, since I have written a program for linux quite a while ago, that I would love to see if I can get it to work on my tablet.

AGAIN: Any help at all would be greatly appreciated, I am still researching for a proper set of instructions that I could follow to make this happen.
« Last Edit: October 20, 2011, 03:30:11 am by almcneill »

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Android - Lazarus for Dummies (like me).
« Reply #1 on: October 20, 2011, 02:51:48 am »
+1
I would also be interested in knowing how to set up a development environment for 'droids.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Android - Lazarus for Dummies (like me).
« Reply #2 on: October 20, 2011, 08:38:12 am »
Here are the step-by-step instructions:

First part of the instructions:

http://wiki.lazarus.freepascal.org/Android_Interface#Configuring_the_Free_Pascal_Compiler_for_Android

Second part of the instructions:

http://wiki.lazarus.freepascal.org/Android_Interface#Compiling_the_example_LCL-Android_Application

Just follow the instructions in the order provided. With which step exactly do you have problems with?

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #3 on: October 20, 2011, 04:17:36 pm »
Thank you sir, when I get a moment today, I will try them, and post my results.

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #4 on: October 20, 2011, 06:02:54 pm »
And here are my results:

PART 1:

Step 1 - Install the cross-binutils

Ok, did this no problem. For opensuse 11.4 I already had it in my repositories list.

But if you do not, using a web browser, it can be located under software.opensuse.org/114/en/
for search term type cross-arm. It will return 1 result for 1-click install, click it and install it.

Step 2 - Configure the cross-binutils

Ok, did exactly as you stated to do.

Step 3 - Install Free Pascal

Ok, no problem.

PART 2:

Now we are ready to compile Android applications using the Lazarus IDE!

Step 1 - Download the source code

Done.

Step 2 - Build it using the Lazarus IDE

Not done, Lazarus returned an error:

"Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127"

I am assuming that I have not set something correctly in my environment.

Please provide direction here.

Step 3 - Build the APK

Not done, maybe due to error in Step 2 above, maybe not. Command prompt returned error:

"anthony@linux-3fnz:~/Downloads/lazarus/temp/androidlcl/android> ant debug
 Buildfile: build.xml"

"BUILD FAILED
 /home/anthony/Downloads/lazarus/temp/androidlcl/android/build.xml:46: taskdef class com.android.ant.SetupTask cannot be found"

Please provide direction here.

Step 4 - Install the APK in your phone and run it

Not quite there yet.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android - Lazarus for Dummies (like me).
« Reply #5 on: October 21, 2011, 04:14:47 am »
Quote
"Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127"
This means your PART 1 Step 3 is done incorrectly, because it should generate ppcarm cross compiler. Do you get ppc386 instead?

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #6 on: October 21, 2011, 04:58:18 am »
Ok, but if it is wrong, then the direction is wrong.  For I followed the directions exactly.  Did I get the ppc386 instead?  I downloaded the only file that was available, it did not state if it was 386 or 64... if you could provide insight, I am willingly to try.

Thanks for responding.

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #7 on: October 21, 2011, 05:29:07 am »
So, I did a search of my PC.  I found under /usr/lib64/fpc/2.4.4 a file named ppcx64.  Also under /usr/bin is a link to this file.  So, I believe I have the correct files installed, Lazarus and FPC that I am using are 64 bit.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Android - Lazarus for Dummies (like me).
« Reply #8 on: October 21, 2011, 07:34:58 am »
Ok, but if it is wrong, then the direction is wrong.  For I followed the directions exactly.  Did I get the ppc386 instead?  I downloaded the only file that was available, it did not state if it was 386 or 64... if you could provide insight, I am willingly to try.

You downloaded the only file that was available where? Did you download it from the link provided in the instructions? This is not just "Install Any Free Pasca", but rather "Install the Free Pascal Cross-Compiler" (I will change this title in the wiki to be more clear). It *must be* that Free Pascal from the instructions. Not just any Free Pascal that you download somewhere else, because it must be a ARM cross-compiler. And you need to configure it as stated there too.

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #9 on: October 21, 2011, 07:48:26 am »
Yes sir, it was the one with the link provided. I will post it here.

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

and this is the file I downloaded:

fpc-2.5.1.arm-linux.tar.gz

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Android - Lazarus for Dummies (like me).
« Reply #10 on: October 21, 2011, 07:53:06 am »
Ok, so try this then:

ln -ls /usr/bin/ppc*

Does ppcrossarm appear? And what about this:

cd /usr/bin
./ppcrossarm

If both work, then you just need to configure Lazarus. Go to the menu Tools->Options and set the compiler Path to "/usr/bin/ppcrossarm", not go back to compiling the example.

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #11 on: October 21, 2011, 07:59:50 am »
Ok, tried what you said and pasted below is exact input/output from terminal;

linux-3fnz:/home/anthony # ls -ls /usr/bin/ppc*
0 lrwxrwxrwx 1 root root 24 Oct 20 08:48 /usr/bin/ppcrossarm -> lib/fpc/2.5.1/ppcrossarm
0 lrwxrwxrwx 1 root root 25 Oct 16 09:59 /usr/bin/ppcx64 -> ../lib64/fpc/2.4.4/ppcx64
linux-3fnz:/home/anthony # cd /usr/bin
linux-3fnz:/usr/bin # ./ppcrossarm
bash: ./ppcrossarm: No such file or directory
linux-3fnz:/usr/bin # ppcrossarm
If 'ppcrossarm' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf ppcrossarm
linux-3fnz:/usr/bin # sh ppcrossarm
sh: ppcrossarm: No such file or directory
linux-3fnz:/usr/bin # ls ppc*
ppcrossarm  ppcx64
linux-3fnz:/usr/bin # ls -l ppc*
lrwxrwxrwx 1 root root 24 Oct 20 08:48 ppcrossarm -> lib/fpc/2.5.1/ppcrossarm
lrwxrwxrwx 1 root root 25 Oct 16 09:59 ppcx64 -> ../lib64/fpc/2.4.4/ppcx64
linux-3fnz:/usr/bin #

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #12 on: October 21, 2011, 08:00:43 am »
My mistake, I typed an incorrect command, let me try again.

Ok, I copied your command directly and pasted into terminal:  ln -ls /usr/bin/ppc*

ln: invalid option -- 'l'
Try `ln --help' for more information.

So, not so great with terminal, but the "l" is not being accepted, so I tried ln -Ls /usr/bin/ppc* and this is what returned:

ln: failed to create symbolic link `/usr/bin/ppcx64': File exists

So, does this mean I just need to configure Lazarus?
« Last Edit: October 21, 2011, 08:05:46 am by almcneill »

almcneill

  • New Member
  • *
  • Posts: 34
Re: Android - Lazarus for Dummies (like me).
« Reply #13 on: October 21, 2011, 08:35:00 am »
Ok, I was hoping for one more chance before I went to bed, but it is 12:30 here in Denver, and I am tired.  I will check tomorrow for hopefully further clues.

And to those that are attempting to guide me through my ignorance: Thank you, it is truly appreciated.  I am sure that there is something simple that is being overlooked.

Again, thanks for all the help, I will check back in the morning.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Android - Lazarus for Dummies (like me).
« Reply #14 on: October 21, 2011, 08:54:59 am »
Ok, I copied your command directly and pasted into terminal:  ln -ls /usr/bin/ppc*

That was a typo on my side, that should have been: ls -ls /usr/bin/ppc*

I just wanted to see if you have the file. From your output:

0 lrwxrwxrwx 1 root root 24 Oct 20 08:48 /usr/bin/ppcrossarm -> lib/fpc/2.5.1/ppcrossarm
0 lrwxrwxrwx 1 root root 25 Oct 16 09:59 /usr/bin/ppcx64 -> ../lib64/fpc/2.4.4/ppcx64

I can see that the link in /usr/bin/ppcrossarm is created wrongly! It should point to ../lib/fpc/2.5.1/ppcrossarm not to lib/fpc/2.5.1/ppcrossarm like now

You failed in this step:

Step 3 - Install the Free Pascal Cross-Compiler

......
[root@localhost usr]# tar -xvf fpc-2.5.1.arm-linux.tar.gz
[root@localhost usr]# ln -s lib/fpc/2.5.1/ppcrossarm bin/ppcrossarm

You did something different here and your link points to a wrong location. You need to delete /usr/bin/ppcrossarm and create the link again.
« Last Edit: October 21, 2011, 09:00:02 am by felipemdc »