Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-07

Crosscompile to Android on arm?

16 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I have a GUI program developed in FPC/Lazarus x64 on Windows. It is an IoT device configuration application which would benefit from being portable, i.e. executable on an Android phone. The devices in question will be placed in locations where configuration would be easier from a phone.

Before I start digging in to the multiple pages I have found on the fpc/Android subject I want to ask if it would be feasible to cross-compile my Windows application for Android phone use?

I have used standard GUI controls in Lazarus for the visual parts and Indy10 (via indylaz) for the TCP/IP communications stuff.

Any advice welcome!
But if it turns out to be a learning path several weeks long it is probably not worth the effort...

Bo Berglund Developer in Sweden

Reply by email

Paul Breneman
to Bo Berglund
Bo Berglund wrote 16 lines
I have a GUI program developed in FPC/Lazarus x64 on Windows. It is an IoT device configuration application which would benefit from being portable, i.e. executable on an Android phone. The devices in question will be placed in locations where configuration would be easier from a phone. Before I start digging in to the multiple pages I have found on the fpc/Android subject I want to ask if it would be feasible to cross-compile my Windows application for Android phone use? I have used standard GUI controls in Lazarus for the visual parts and Indy10 (via indylaz) for the TCP/IP communications stuff. Any advice welcome! But if it turns out to be a learning path several weeks long it is probably not worth the effort...

You *hope* to compile a program *directly* on an Android phone with *little* effort? :)

You could possibly hire me (or other that I know).

Or we could trade things?

On 6/11/18 I wrote a message on this forum to you about a security dongle I need to use in Lazarus. I'll trade some work for that code!

I've spent a bit of time investigating similar things:

http://www.turbocontrol.com/userland.htm

http://controlpascal.com/self-hosted.htm

I got a couple of these kits several years ago:
https://www.anaren.com/search/iot%20product%20bluetooth%20smart%20development%20kit

A company who builds waterproof equipment could hopefully use inexpensive Android tablets occasionally to change equipment settings (a *lot* less expensive than adding waterproof user IO equipment to their gear).

I'd enjoy hearing more ideas from others!

Best regard,
Paul
www.ControlPascal.com

Reply by email

Paul Breneman
to Paul Breneman

Sorry that my Anaren link was bad. I haven't found my *old* development kit yet but this works better:
https://www.anaren.com/catalog/wireless-transceivers/proprietary-rf

My last message to you Bo:
http://lists.lazarus-ide.org/pipermail/lazarus/2018-June/234962.html

Paul Breneman wrote 48 lines
On 07/25/2018 08:04 AM, Bo Berglund via Lazarus wrote: > I have a GUI program developed in FPC/Lazarus x64 on Windows. > It is an IoT device configuration application which would benefit from > being portable, i.e. executable on an Android phone. The devices in > question will be placed in locations where configuration would be > easier from a phone. > > Before I start digging in to the multiple pages I have found on the > fpc/Android subject I want to ask if it would be feasible to > cross-compile my Windows application for Android phone use? > > I have used standard GUI controls in Lazarus for the visual parts and > Indy10 (via indylaz) for the TCP/IP communications stuff. > > Any advice welcome! > But if it turns out to be a learning path several weeks long it is > probably not worth the effort... You *hope* to compile a program *directly* on an Android phone with *little* effort?  :) You could possibly hire me (or other that I know). Or we could trade things? On 6/11/18 I wrote a message on this forum to you about a security dongle I need to use in Lazarus.  I'll trade some work for that code! I've spent a bit of time investigating similar things: http://www.turbocontrol.com/userland.htm http://controlpascal.com/self-hosted.htm I got a couple of these kits several years ago: https://www.anaren.com/search/iot%20product%20bluetooth%20smart%20development%20kit A company who builds waterproof equipment could hopefully use inexpensive Android tablets occasionally to change equipment settings (a *lot* less expensive than adding waterproof user IO equipment to their gear). I'd enjoy hearing more ideas from others! Best regard, Paul www.ControlPascal.com

Reply by email

Paul Breneman
to Paul Breneman

Sorry again Bo that I missed your *crosscompile* (multiple times)! I'm sure others can help you with that much better than I can. :)

Paul Breneman wrote 58 lines
Sorry that my Anaren link was bad.  I haven't found my *old* development kit yet but this works better: https://www.anaren.com/catalog/wireless-transceivers/proprietary-rf My last message to you Bo: http://lists.lazarus-ide.org/pipermail/lazarus/2018-June/234962.html On 07/25/2018 11:47 AM, Paul Breneman via Lazarus wrote: > On 07/25/2018 08:04 AM, Bo Berglund via Lazarus wrote: >> I have a GUI program developed in FPC/Lazarus x64 on Windows. >> It is an IoT device configuration application which would benefit from >> being portable, i.e. executable on an Android phone. The devices in >> question will be placed in locations where configuration would be >> easier from a phone. >> >> Before I start digging in to the multiple pages I have found on the >> fpc/Android subject I want to ask if it would be feasible to >> cross-compile my Windows application for Android phone use? >> >> I have used standard GUI controls in Lazarus for the visual parts and >> Indy10 (via indylaz) for the TCP/IP communications stuff. >> >> Any advice welcome! >> But if it turns out to be a learning path several weeks long it is >> probably not worth the effort... > > You *hope* to compile a program *directly* on an Android phone with > *little* effort?  :) > > You could possibly hire me (or other that I know). > > Or we could trade things? > > On 6/11/18 I wrote a message on this forum to you about a security > dongle I need to use in Lazarus.  I'll trade some work for that code! > > I've spent a bit of time investigating similar things: > > http://www.turbocontrol.com/userland.htm > > http://controlpascal.com/self-hosted.htm > > I got a couple of these kits several years ago: > https://www.anaren.com/search/iot%20product%20bluetooth%20smart%20development%20kit > > > A company who builds waterproof equipment could hopefully use > inexpensive Android tablets occasionally to change equipment settings > (a *lot* less expensive than adding waterproof user IO equipment to > their gear). > > I'd enjoy hearing more ideas from others! > > Best regard, > Paul > www.ControlPascal.com

Reply by email

Paul Breneman
to Bo Berglund
Bo Berglund wrote 10 lines
On Wed, 25 Jul 2018 11:47:06 -0400, Paul Breneman via Lazarus wrote: > You *hope* to compile a program *directly* on an Android phone with > *little* effort? :) Did you read "Crosscompile" as compiling *on* android? I used cross to indicate that the compilation would be done elsewhere like on a regular PC but *targeting* Android.

Yes, I should *finish* my coffee before writing emails! :)

Reply by email

Bo Berglund
to Paul Breneman: You *hope* to compile a program *directly* on an Android phone with *little* effort? :)…
Paul Breneman wrote
On 6/11/18 I wrote a message on this forum to you about a security dongle I need to use in Lazarus. I'll trade some work for that code!

Since I could not make use of the OBJ file for the Sentinel Superpro dongle I started looking for dongle replacements and I got a sample from Keylok (a Keylok3 dongle) that has similar capabilities. Its main attraction is that it does not use a driver installed in the operating system, they say it is "driver-less".

But instead they provide a dll to interface with the dongle via the operating system standard USB communications. As an alternative they also have OBJ library file solution which means that the interface will be included in ones own exe file, no dll needed. However they did not have an OBJ file for even Delphi7 for Keylok3...

And an OBJ is probably dev IDE dependent too, so the dll is the only way to go if one needs FPC.

I have tested it with Delphi7 (as a compatibility check, I expect my code to also run on Lazarus/Fpc) and it is simple enough to get going on Windows.
But I put it on hold for the summer vacations...

My project for the IoT stuff is private using ESP8266 based WiFi boards to monitor and report here and there around my home... So this is something I do now and then even in this temperature...

Bo Berglund Developer in Sweden

Reply by email

Paul Breneman
to Bo Berglund
Bo Berglund wrote 29 lines
On Wed, 25 Jul 2018 11:47:06 -0400, Paul Breneman via Lazarus wrote: > On 6/11/18 I wrote a message on this forum to you about a security > dongle I need to use in Lazarus. I'll trade some work for that code! > Since I could not make use of the OBJ file for the Sentinel Superpro dongle I started looking for dongle replacements and I got a sample from Keylok (a Keylok3 dongle) that has similar capabilities. Its main attraction is that it does not use a driver installed in the operating system, they say it is "driver-less". But instead they provide a dll to interface with the dongle via the operating system standard USB communications. As an alternative they also have OBJ library file solution which means that the interface will be included in ones own exe file, no dll needed. However they did not have an OBJ file for even Delphi7 for Keylok3... And an OBJ is probably dev IDE dependent too, so the dll is the only way to go if one needs FPC. I have tested it with Delphi7 (as a compatibility check, I expect my code to also run on Lazarus/Fpc) and it is simple enough to get going on Windows. But I put it on hold for the summer vacations... My project for the IoT stuff is private using ESP8266 based WiFi boards to monitor and report here and there around my home... So this is something I do now and then even in this temperature...

Thanks for *all* of that info Bo. My favorite time in Sweden (in 1992) I visited the Vasa. Maybe if I visit again we can meet up? https://www.vasamuseet.se

Reply by email

Bo Berglund
to Paul Breneman
Paul Breneman wrote
Thanks for *all* of that info Bo. My favorite time in Sweden (in 1992) I visited the Vasa. Maybe if I visit again we can meet up? https://www.vasamuseet.se

Yes, that is the top attraction in Stockholm! The museum has been vastly improved since 1992, it is worth a re-visit.

Concerning my config app I have checked that the code runs on ARM by building the same sources I use on my Win7 PC also on a RaspberryPi3B. Same FPC and Lazarus versions (3.0.4/1.8.4).

No problems there except an annoying display difference, all of the controls on my form were slightly misplaced in RPi3 and the captions used a font that was too big and did not fit the text inside the buttons...

Is there a way to ensure that the GUI design stays put when moving about on different target systems?

Bo Berglund Developer in Sweden

Reply by email

R0b0t1
to Bo Berglund: I have a GUI program developed in FPC/Lazarus x64 on Windows. It is an IoT device…

https://wiki.gentoo.org/wiki/Project:Android

Bo Berglund wrote 27 lines
I have a GUI program developed in FPC/Lazarus x64 on Windows. It is an IoT device configuration application which would benefit from being portable, i.e. executable on an Android phone. The devices in question will be placed in locations where configuration would be easier from a phone. Before I start digging in to the multiple pages I have found on the fpc/Android subject I want to ask if it would be feasible to cross-compile my Windows application for Android phone use? I have used standard GUI controls in Lazarus for the visual parts and Indy10 (via indylaz) for the TCP/IP communications stuff. Any advice welcome! But if it turns out to be a learning path several weeks long it is probably not worth the effort... -- Bo Berglund Developer in Sweden -- _______________________________________________ Lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

Reply by email

R0b0t1
to Bo Berglund
Bo Berglund wrote 11 lines
On Wed, 25 Jul 2018 13:57:54 -0500, R0b0t1 via Lazarus wrote: >https://wiki.gentoo.org/wiki/Project:Android That page does not contain a single instance of the words "pascal" or "lazarus". Seems like it is a dead end for my question about crosscompiling an *existing* fpc/lazarus application targeting Android on arm (= phones)...

My apologies, I was a bit confused. Mr. Breneman mentioned compiling for Android from Android in one of his posts. If you really wanted to do that, following the steps on that page is probably the easiest way to accomplish it. Though now I think there are some other distro-unpackers that will run on unrooted phones. Gentoo is probably the best and has the most up-to-date software.

If you mean to go from x86[_64] -> Android then I am very interested in the answer to this question. At most I found
http://wiki.lazarus.freepascal.org/Android_tutorial some time ago.

Cheers,
R0b0t1

Reply by email

Bo Berglund
to Bo Berglund: On Wed, 25 Jul 2018 13:07:10 -0400, Paul Breneman via Lazarus Yes, that is the top…
Bo Berglund wrote 8 lines
Concerning my config app I have checked that the code runs on ARM by building the same sources I use on my Win7 PC also on a RaspberryPi3B. Same FPC and Lazarus versions (3.0.4/1.8.4). No problems there except an annoying display difference, all of the controls on my form were slightly misplaced in RPi3 and the captions used a font that was too big and did not fit the text inside the buttons...

I was wrong, there ARE problems!
The ported code starts up fine on Raspberry Pi, but as soon as I try to connect a TCP socket connection to the device the program crashes hard.
No dialog or anything, it just disappears from sight!!!

As I stated I have created the program from scratch on Windows7 using FPC/Lazarus (64 bit version) and on Windows it works just fine. It uses Indy10 for TCP communications.

Then I zipped up the sources and put them on the RPi3 box where I have FPC 3.0.4 and Lazarus 1.8.4.
Opened the project in Lazarus and compiled and ran the program.

So I have NOT edited the code for any Win/Linux differences for example, is that needed?

For example in some console apps I have made also for both Windows and
Raspbian I have this in the lpr file:
  {$IFDEF UNIX}
    {$IFDEF UseCThreads}
    cthreads,
    {$ENDIF}
  {$ENDIF}

If that is needed also here, where should it be put?

Bo Berglund Developer in Sweden

Reply by email

Sven Barth
to Bo Berglund

Bo Berglund via Lazarus schrieb am Do., 26.
Juli 2018, 10:02:

Then I zipped up the sources and put them on the RPi3 box where I have FPC 3.0.4 and Lazarus 1.8.4. Opened the project in Lazarus and compiled and ran the program.

Did you run it from inside Lazarus? Thus with the debugger? That might help you find the problem.

So I have NOT edited the code for any Win/Linux differences for example, is that needed?

Maybe, depending on your program.

Show quoted text 11 lines
For example in some console apps I have made also for both Windows and Raspbian I have this in the lpr file: {$IFDEF UNIX} {$IFDEF UseCThreads} cthreads, {$ENDIF} {$ENDIF} If that is needed also here, where should it be put?

Also in the main project file in front of any other units. If your program indeed uses threads (don't know whether Indy uses them) then you'll also either need to add UseCThreads to the project defines or remove the "$ifdef UseCThreads" so that the cthreads unit is always used on Unix-like systems.

Regards,
Sven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180726/c581f615/attachment.html>

Reply by email

Bo Berglund
to Sven Barth
Sven Barth wrote 15 lines
> For example in some console apps I have made also for both Windows and > Raspbian I have this in the lpr file: > {$IFDEF UNIX} > {$IFDEF UseCThreads} > cthreads, > {$ENDIF} > {$ENDIF} > > If that is needed also here, where should it be put? > Also in the main project file in front of any other units. If your program indeed uses threads (don't know whether Indy uses them) then you'll also either need to add UseCThreads to the project defines or remove the "$ifdef UseCThreads" so that the cthreads unit is always used on Unix-like systems.

Indy does use threads extensively...
Since I could not find any place to set a project wide defined symbol UseCThreads I did this instead in the lpr file:

program WiFiConfig;
{$mode objfpc}{$H+}

uses

  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, indylaz, FormMainConfig, wificommhandler
  { you can add units after this };
{$R *.res}
begin
  RequireDerivedFormResource := True;
  Application.Initialize;
  Application.CreateForm(TfrmMainConfig, frmMainConfig);
  Application.Run;
end.

After this the program does no longer crashes when I try to connect to the device, but it does not connect either because I am having problems making OpenVPN to the network where the device lives work from the RPi box.
I have to solve this somehow, it works fine from my Windows7 PC so there I can interact with the device.
Problem for another forum, though.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote 7 lines
After this the program does no longer crashes when I try to connect to the device, but it does not connect either because I am having problems making OpenVPN to the network where the device lives work from the RPi box. I have to solve this somehow, it works fine from my Windows7 PC so there I can interact with the device. Problem for another forum, though.

Worked around it by copying the executable from my local RPi to another RPi unit running at home using FileZilla on my Win7 laptop. Then started it in a VNC window on tghe RPI back home.

In this case the application works just fine to connect to the ESP8277 device and retrieve the config data! :)

So I am back to my original enquiry:
Can I also cross-compile this application to run as an app on an Android phone or tablet?
If it is possible, exactly how can it be done?

Bo Berglund Developer in Sweden

Reply by email