Recent

Author Topic: Lazarus on Windows for Android  (Read 29290 times)

polypress

  • Jr. Member
  • **
  • Posts: 91
Lazarus on Windows for Android
« on: August 12, 2013, 10:33:02 am »
I am looking to get a new smart phone. The old one is based on Windows Mobile 6.5 and has worked well but is slow. Applications can crash if more than a few are loaded.
The new phone would be Windows Phone 8 or Android based, and applications written for WM6.5 (WinCE) are not compatible with either of these.
Can Android applications be written on Windows XP based Lazarus/FPC (1.0.10/2.6.2) or does is have to be Linux based Lazarus/FPC?

Regards

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus on Windows for Android
« Reply #1 on: August 12, 2013, 06:32:58 pm »
Quote
Can Android applications be written on Windows XP based Lazarus/FPC (1.0.10/2.6.2)
Yes, but not with FPC 2.6.2. Use FPC trunk with native arm-android support (the hacked 2.5.1 might work, but I don't suggest that anymore)
Quote
or does is have to be Linux based Lazarus/FPC?
No

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #3 on: August 16, 2013, 01:22:26 pm »
I have tried to access the skydrive site but each time it causes ie8 to crash.
Is this site or this link OK?

Please confirm before I try again.

Regards

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Lazarus on Windows for Android
« Reply #4 on: August 18, 2013, 02:10:30 am »
Sorry.

Please, try this:

https://skydrive.live.com/?cid=89AE6B50650182C6&id=89AE6B50650182C6%21129

or: https://skydrive.live.com/?cid=89ae6b50650182c6

And this:       "Laz4Android1.1-41139-FPC2.7.1.7z"

Thank you.
« Last Edit: August 18, 2013, 02:18:40 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #5 on: August 19, 2013, 03:04:38 pm »
Thank you for the links jmpessoa.
I have downloaded the files and installed them, creating a running version of 1.1/2.7.1 together with various files such as arm-linux-androideabi-as.exe, arm-linux-androideabi-id.exe, arm-linux-androideabi-strip.exe, but I'm not sure what to do with them now.
If I try to use them in the environment file path then I'm told it should be ppcrossarm.exe (as for wince, but fpc.cfg is missing) or fpc.exe or ppc386.exe (as for win32). I have project compiler target os as android and cpu family as arm.
Is there a link to show how to use this installation for android?

Regards

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #6 on: August 19, 2013, 04:54:30 pm »
Further to my last post, I have gone through the pdf file which came with the installation.

Unfortunately it is in Chinese (with a little English content) showing a test with a project called androidlcltest.lpr.

On testing it with the paths setup as best I could with the information available, it has come up with errors such as "illegal parameter -CpARMV6" and "Fatal: cannot find unit system used by fcllaz of package FCL" which it appears to be trying to register, and this prevents further processing.

Any help to resolve this one example would be appreciated. If I can get this one to work, then hopefully I can get other more demanding applications to work.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus on Windows for Android
« Reply #7 on: August 19, 2013, 06:09:53 pm »
Quote
I have downloaded the files and installed them, creating a running version of 1.1/2.7.1 together with various files such as arm-linux-androideabi-as.exe, arm-linux-androideabi-id.exe, arm-linux-androideabi-strip.exe, but I'm not sure what to do with them now.
ld and as are linker and assembler, respectively. strip is not really required, you can just tell the compiler not to generate debugging info. You'll need to rename the linker and assembler prefix to arm-linux- (I assume this FPC version still uses the hacked arm-linux target instead of native arm-android), because by default fpc.cfg only contains -XP$FPCTARGET- which will be expanded to (on arm-linux target) -XParm-linux-, which will make searching of assembler and linker fails, because the name differs (e.g. arm-linux-androideabi-as instead of arm-linux-as). You can also modify the -XP in fpc.cfg or specificially specify -XP only for this project to match the name of the assembler and linker.
Quote
If I try to use them in the environment file path then I'm told it should be ppcrossarm.exe (as for wince, but fpc.cfg is missing) or fpc.exe or ppc386.exe (as for win32)
fpc -Parm will call ppcrossarm while fpc only will call the host compiler (ppc386 in your case).
Quote
I have project compiler target os as android and cpu family as arm.
If you're using hacked arm-linux, then your os target should be linux instead of android.
Quote
On testing it with the paths setup as best I could with the information available, it has come up with errors such as "illegal parameter -CpARMV6"
The compiler might not be built with ARMv6 code generation support, you should know exactly how the compiler is built (i.e. what options are passed).
Quote
and "Fatal: cannot find unit system used by fcllaz of package FCL"
Either fpc.cfg misses path to arm-linux version of the basic units or because of the previous error.
« Last Edit: August 19, 2013, 06:12:27 pm by Leledumbo »

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #8 on: August 19, 2013, 07:44:07 pm »
Thank you for your prompt response Leledumbo.

It will take a while to absorb and incorporate all of your suggestions so I probably won't be live for a while.

However, the android files are of the form "arm-linux-androideabi-as.exe". Are you saying I need to convert its name (to arm-androideabi-as.exe or arm-android-as.exe or arm-linux-as.exe) or to change the file name called from lazarus to "arm-linux-androideabi-as.exe" or to change file names within fpc.cfg?

What are -XP$FPCTARGET- (the XP bit) and -XParm-linux- and fpc -Parm and where are they called?

I don't know if I'm using a hacked arm-linux - it came from Skydrive which seems to be connected with Microsoft, so I assume it shouldn't be hacked.

How can I find out if the compiler was built with ARMv6 code generation support?

Which part of fpc.cfg defines the path to the arm-linux version of the basic units?

The download was supposedly a fully working 1.1/2.7.1 + example, so could it be the environment needs to be modified?

I am familiar with assembler and Delphi (Lazarus) programming, but this all seems a little more difficult.

Regards

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Lazarus on Windows for Android
« Reply #9 on: August 20, 2013, 01:58:00 am »
Hi!

1. From original Post:
    http://forum.lazarus.freepascal.org/index.php/topic,20918.msg121775.html#msg121775

After decompression:

--> Find "build.bat" batch file, right-click for edit. if necessary modify line 4:
     SETFPC_BIN_PATH = F:\laz4android   
     for something more convenient for you.
     For me:  SETFPC_BIN_PATH = C:\laz4android 

--> now double-click the "build.bat' to build Lazarus and wait for the completion of the batch...

2.  To compile "androidlcltest" See the zariq post here:
     http://forum.lazarus.freepascal.org/index.php/topic,21544.0.html


3. After some experimentation I got the following configuration (for my comfort or laziness  :D)
    as shown in the accompanying figures (Attachments).

   My Comment about "Other"

   I think just  this is necessary:

   -dANDROID -Xd -CpArmV6 -CfSoft -FLC:\adt32\ndk7\platforms\android-8\arch-arm\usr\lib\libdl.so

    where -CSoft can may be substituted by -CVfpV3 ... etc.
   
    In fact, if you can omit this part

   -FUC:\adt32\eclipse\workspace\App1\obj\JNIHello -oC:\adt32\eclipse\workspace\App\libs\armeabi\libjnihello.so

and act manually this tasks....

Greetings!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus on Windows for Android
« Reply #10 on: August 20, 2013, 06:15:03 pm »
I'll wait until you do what jmpessoa say before I answer, perhaps the package is already designed as such (i.e. requires running some batch file before used).

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: Lazarus on Windows for Android
« Reply #11 on: August 21, 2013, 07:31:51 am »
HI! I am the founder of this package,as jmpessoa say this package can compiled androidlcltest project,you just do this:
1.download laz4android1.1-41139-FPC2.7.1.7z from http://sdrv.ms/12cHbIZ

2.decompression this file to any path,etc : c:\laz4android

3.edit "build.bat" line 4
  SET FPC_BIN_PATH = F:\laz4android
 this line change to  SET FPC_BIN_PATH = c:\laz4android

4.now double click the "build.bat",now you can see a command form is running ,it's building lazarus.exe,please waiting for build finished.

5.after builded lazarus.exe ,you can run the lazarus.exe to open the androidlcltest.lpr ,which is location c:\laz4android\examples\androidlcl. before compile this project ,you must download android NDK and extract it.

7.adjust project's libraries to your NDK path,this menu: project->project options->paths(left)->libraries(right) .

8.if the libraries path is correct ,now can CTRL+F9 to compile this androidlcltest project, a file which name is "liblclapp.so" should created at C:\laz4android\examples\androidlcl\android\libs\armeabi

9.now edit "generate_debug_key.bat" ,run it to create a key.you must already installed JDK ok.

10. edit "build_debug_apk.bat",run it to build a android apk package.you must already installed Android SDK ok.

hope can helped you! Greeting!
sorry for my bad english.
« Last Edit: August 21, 2013, 07:50:59 am by truetom »
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #12 on: August 23, 2013, 02:48:32 pm »
Hello truetom
I have followed your instructions fully (I think) but when I get to compile with Ctrl+F9 I am given the following message "Fatal: cannot find unit system used by fcllaz of package FCL". According to Leledumbo this is because either fpc.cfg misses path to arm-linux version of the basic units or because the compiler might not be built with ARMv6 code generation support, [you should know exactly how the compiler is built (i.e. what options are passed)]. I have searched fpc.cfg and there is no sign of the path for arm-linux, but also, is the compiler built with ARMv6 code generation support? If your installation works OK, then I assume it is, or could each installation have different levels of (ARMv6) support?

Would it help if I attached some files to these posts? If so, which do you suggest?

Regards

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Lazarus on Windows for Android
« Reply #13 on: August 23, 2013, 06:54:54 pm »
Hi!

Do you did the zariq hint?  http://forum.lazarus.freepascal.org/index.php/topic,21544.0.html

Quote
To compile androidlcltest had to change the target from Linux to android
and deselect -WR(relocatable) option under code generation. didn't have to change paths
to android ndk / sdk which I have installed in c:\android. Also the "so" extention is not added,
so need to rename the file or add it in the project options.

Greetings!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: Lazarus on Windows for Android
« Reply #14 on: August 25, 2013, 09:26:22 am »
Hello polypress.
I guess you select the project's Target OS is wrong.
Check this menu:
Project -> project options -> Code generation (left) -> Target OS:android    Target CPU family: arm  (right)
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/