Lazarus

Programming => Operating Systems => Android => Topic started by: almcneill on October 20, 2011, 12:43:31 am

Title: Android - Lazarus for Dummies (like me).
Post by: almcneill 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: IPguy 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc 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?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: Leledumbo 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?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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 #
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc 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.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 04:52:08 pm
Sir, I did exactly as you asked.  Followed the steps again (from step 3), below are the results:

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

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

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

So, I believe that I may not have something pointing to the right place under lazarus, would you agree?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc on October 21, 2011, 05:17:34 pm
Let's go back to verity that your compiler is working before:

cd /usr/bin/
ls -ls ppc*
./ppcrossarm

Could you post the results of these commands?

What is written in your Lazarus in the menu "Tools->Options->Compiler Path"?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 05:32:36 pm
Yes Sir, posted below:

anthony@linux-3fnz:/usr/bin> ls -ls ppc*
0 lrwxrwxrwx 1 root root 24 Oct 21 08:43 ppcrossarm -> lib/fpc/2.5.1/ppcrossarm
0 lrwxrwxrwx 1 root root 24 Oct 20 08:48 ppcrossarm.org -> lib/fpc/2.5.1/ppcrossarm
0 lrwxrwxrwx 1 root root 25 Oct 16 09:59 ppcx64 -> ../lib64/fpc/2.4.4/ppcx64
anthony@linux-3fnz:/usr/bin>
anthony@linux-3fnz:/usr/bin>
anthony@linux-3fnz:/usr/bin>
anthony@linux-3fnz:/usr/bin> ./ppcrossarm
bash: ./ppcrossarm: No such file or directory
anthony@linux-3fnz:/usr/bin>

I think the problem may lay in the last line "../lib64/fpc/2.4.4/ppcx64" ?

Compiler path > /usr/bin/fpc
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 05:44:01 pm
I think I may have found a large part of the problem.

In your Part 1 Step 2 > Step 2 - Configure the cross-binutils

su
mv /usr/bin/arm-linux-as /usr/bin/arm-linux-as_org
gedit /usr/bin/arm-linux-as

I apologize for this, I had a long day yesterday and this step was very early on BUT, opensuse does not put this in the same place.  Opensuse puts this file in the following directory:

/opt/cross/bin/arm-linux-as  - I believe that due to my lack of pointing this out to you, may be the culprit behind the whole probelm?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc on October 21, 2011, 05:47:39 pm
anthony@linux-3fnz:/usr/bin> ls -ls ppc*
0 lrwxrwxrwx 1 root root 24 Oct 21 08:43 ppcrossarm -> lib/fpc/2.5.1/ppcrossarm
0 lrwxrwxrwx 1 root root 24 Oct 20 08:48 ppcrossarm.org -> lib/fpc/2.5.1/ppcrossarm
0 lrwxrwxrwx 1 root root 25 Oct 16 09:59 ppcx64 -> ../lib64/fpc/2.4.4/ppcx64

Your ppcrossarm is still pointing to the wrong location... (as I had explained in this reply: http://www.lazarus.freepascal.org/index.php/topic,15012.msg80250.html#msg80250 )

Try this:

cd /usr/bin
rm ppcrossarm
cd /usr
ln -s lib/fpc/2.5.1/ppcrossarm bin/ppcrossarm

Quote
I think the problem may lay in the last line "../lib64/fpc/2.4.4/ppcx64" ?

No, it is ppcrossarm that is wrong...
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 05:50:08 pm
Yes Sir, I did read the topic.  I will do this again and try post the results.

Before I try it again though, I did try this command:

anthony@linux-3fnz:/usr/bin> ls -l ppcrossarm
lrwxrwxrwx 1 root root 24 Oct 21 08:43 ppcrossarm -> lib/fpc/2.5.1/ppcrossarm

So, it looks as though it is pointing to the correct place.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 05:57:24 pm
Results:

linux-3fnz:/usr/bin # rm ppcrossarm
linux-3fnz:/usr/bin # cd /usr
linux-3fnz:/usr # ln -s lib/fpc/2.5.1/ppcrossarm bin/ppcrossarm

linux-3fnz:/usr/bin # ls -ls ppcrossarm
0 lrwxrwxrwx 1 root root 24 Oct 21 09:54 ppcrossarm -> lib/fpc/2.5.1/ppcrossarm

Same as before.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc on October 21, 2011, 06:01:37 pm
This seams to defy logic .... I wonder if your shell works differently then mine? What about this ones:

cd /usr/bin
rm ppcrossarm
ls -l ppc*
ln -s ../lib/fpc/2.5.1/ppcrossarm ppcrossarm
ls -l ppc*
./ppcrossarm

lrwxrwxrwx 1 root root 24 Oct 21 08:43 ppcrossarm -> lib/fpc/2.5.1/ppcrossarm

So, it looks as though it is pointing to the correct place.

That's the wrong place, it needs to point to ../lib/fpc/2.5.1/ppcrossarm
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 06:08:52 pm
"This seams to defy logic .... I wonder if your shell works differently then mine?"  Ok, so I am not crazy, thank you for saying that.

Here are the posted results, notice the error, so something is definitely different between yours and mine.

linux-3fnz:/usr/bin # rm ppcrossarm
linux-3fnz:/usr/bin # ls -l ppc*
lrwxrwxrwx 1 root root 25 Oct 16 09:59 ppcx64 -> ../lib64/fpc/2.4.4/ppcx64

linux-3fnz:/usr/bin # ls -s ../lib/fpc/2.5.1/ppcrossarm ppcrossarm
ls: cannot access ppcrossarm: No such file or directory
2084 ../lib/fpc/2.5.1/ppcrossarm

linux-3fnz:/usr/bin # ls -l ppc*
lrwxrwxrwx 1 root root 25 Oct 16 09:59 ppcx64 -> ../lib64/fpc/2.4.4/ppcx64
Title: Re: Android - Lazarus for Dummies (like me).
Post by: Laksen on October 21, 2011, 07:38:04 pm
almcneill, ln and ls are two different commands. You have messed that up in your last post
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 08:24:50 pm
Laksen,

I understand that, ln > link command, ls > directory listing.  If you follow the posts, I have been doing as instructed.  If you think I mistyped something, could you please point it out to me (the exact line) so that I may correct it.

Thanks.

And I do truly mean thanks, to all that are replying, especially felipemdc, I am sure at this point his frustration level with my problem is pretty high.  I do truly appreciate the help and efforts that are taking place.

As a side note, if there will be a "full" version of the 2.5.1 fpc coming out (supporting the android), I am patient enough to wait for it.  Please understand, that I write my own programs for enjoyment, not money, so if I cannot get this working at this time (but rather at a later time), it does not impact me in any way.  I am just doing this so that I may further my own personal skills.

Not to mention the fact that I have tried to program in C++ (and variants thereof), and I have always been more comfortable with the Pascal language.  At one point I was trying to incorporate the Pascal language into KDevelop 4 (it use to be part of previous versions, but not version 4), and I had asked for help with this on other websites, only to be told time and again that "Pascal is a dead language".  I do not believe this, and thanks to the Lazarus/Freepascal website (not to mention how many views have hit this post alone), I see that I am not the only one with this opinion.

With that being said, huge props to the members that maintain the lazarus software, without them, I would have nothing to look forward to.  I know what is involved when I write my own programs, I can only imagine what they must go through, not only continually updating/improving lazarus/fpc, but then to have to deal with problems like mine.

I can't say it enough, Thanks... you all do a great job.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 08:31:51 pm
Laksen, you were correct, I went back and thoroughly checked my commands/output again, spotted the error you were talking about, restarted, posted results below:

linux-3fnz:/usr/bin # rm ppcrossarm
linux-3fnz:/usr/bin # ls -l ppc*
lrwxrwxrwx 1 root root 25 Oct 16 09:59 ppcx64 -> ../lib64/fpc/2.4.4/ppcx64
linux-3fnz:/usr/bin # ln -s ../lib/fpc/2.5.1/ppcrossarm ppcrossarm
linux-3fnz:/usr/bin # ls -l ppc*
lrwxrwxrwx 1 root root 27 Oct 21 12:30 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 # ./ppcrossarm
Free Pascal Compiler version 2.5.1 [2011/01/19] for arm
Copyright (c) 1993-2010 by Florian Klaempfl
/usr/lib/fpc/2.5.1/ppcrossarm [options] <inputfile> [options]
Put + after a boolean switch option to enable it, - to disable it
  -a     The compiler doesn't delete the generated assembler file
      -al        List sourcecode lines in assembler file
      -an        List node info in assembler file
      -ap        Use pipes instead of creating temporary assembler files
      -ar        List register allocation/release info in assembler file
      -at        List temp allocation/release info in assembler file
  -A<x>  Output format:
      -Adefault  Use default assembler
      -Aas       Assemble using GNU AS
  -b     Generate browser info
      -bl        Generate local symbol info
  -B     Build all modules
  -C<x>  Code generation options:
      -C3<x>     Turn on ieee error checking for constants
      -Ca<x>     Select ABI, see fpc -i for possible values
      -Cb        Generate big-endian code
      -Cc<x>     Set default calling convention to <x>
      -CD        Create also dynamic library (not supported)
*** press enter ***
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 08:48:15 pm
Ok, a step further, after what was pointed out to me previously, and with the last output being shown, I again tried to build the program with lazarus, below is the output:

androidlcltest.lpr(1,1) Fatal: Can't find unit Interfaces used by androidlcltest
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc on October 21, 2011, 08:53:36 pm
Ok, excellent, finally the compiler is working =)

Ok, a step further, after what was pointed out to me previously, and with the last output being shown, I again tried to build the program with lazarus, below is the output:

androidlcltest.lpr(1,1) Fatal: Can't find unit Interfaces used by androidlcltest

Which version of Lazarus are you using? Is it the very latest SVN?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 21, 2011, 08:55:27 pm
I do not believe so Sir, the version that I currently have is: Lazarus - 0.9.30.2RC1
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 22, 2011, 06:17:04 am
Update:

So, just for the sake of trying, I just installed the lazarus svn version 0.9.31.  Went back and tried to build the project under lazarus and this time I was provided with a different error (posted below):

/usr/lib64/lazarus/packager/registration/lazaruspackageintf.pas(110) Error: Assembler arm-linux-as not found, switching to external assembling
/usr/lib64/lazarus/packager/registration/lazaruspackageintf.pas(110) Fatal: There were 1 errors compiling module, stopping

So, now I believe that I am down to just pointing the compiler in the right direction, does this sound correct?  If so, can you please help with this?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: Laksen on October 22, 2011, 06:42:16 am
It cannot find your binutils that you should have installed in step 1. If you can't run arm-linux-as and arm-linux-ld from a terminal then you have a problem there
Title: Re: Android - Lazarus for Dummies (like me).
Post by: almcneill on October 22, 2011, 06:53:02 am
Laksen, I believe that you are correct, below is a quote from an earlier post of mine:

This is the step directed to use:
"su
mv /usr/bin/arm-linux-as /usr/bin/arm-linux-as_org
gedit /usr/bin/arm-linux-as"

(my response):
"Opensuse puts this file in the following directory:

/opt/cross/bin/arm-linux-as"

Also, the arm-linux-ld is located there, I verified this after reading your post, do you have a suggestion to correct this?  Any help would be appreciated.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: felipemdc on October 22, 2011, 08:39:58 am
Just symlink or copy them to the correct position.
Title: Re: Android - Lazarus for Dummies (like me).
Post by: Diego on August 24, 2014, 07:41:16 pm
Hello, I'm having a problem, follow the step by step of http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM.

I'm trying to build lazarus and I get the error: /home/mint/lazarus/packager/registration/lazaruspackageintf.pas(104) Error: Assembler arm-linuxas not found, switching to external assembling

Could anyone help me?
Title: Re: Android - Lazarus for Dummies (like me).
Post by: DelphiFreak on August 24, 2014, 09:51:10 pm
Hi,

here is a setup but it is for windows only.

If you are interested, then please download and read first the .pdf-file and then the setup.exe from here:

http://sourceforge.net/projects/laztoapk/files/?source=navbar (http://sourceforge.net/projects/laztoapk/files/?source=navbar)

Good luck.

TinyPortal © 2005-2018