Discussion:
[Lazarus] Crosscompile to Android on arm?
Bo Berglund via Lazarus
2018-07-25 12:04:42 UTC
Permalink
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

--
Paul Breneman via Lazarus
2018-07-25 15:47:06 UTC
Permalink
Post by Bo Berglund via Lazarus
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
--
Paul Breneman via Lazarus
2018-07-25 16:24:54 UTC
Permalink
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
Post by Paul Breneman via Lazarus
Post by Bo Berglund via Lazarus
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!
http://www.turbocontrol.com/userland.htm
http://controlpascal.com/self-hosted.htm
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
--
Paul Breneman via Lazarus
2018-07-25 16:32:20 UTC
Permalink
Sorry again Bo that I missed your *crosscompile* (multiple times)! I'm
sure others can help you with that much better than I can. :)
Sorry that my Anaren link was bad.  I haven't found my *old* development
https://www.anaren.com/catalog/wireless-transceivers/proprietary-rf
http://lists.lazarus-ide.org/pipermail/lazarus/2018-June/234962.html
Post by Paul Breneman via Lazarus
Post by Bo Berglund via Lazarus
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!
http://www.turbocontrol.com/userland.htm
http://controlpascal.com/self-hosted.htm
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
--
Bo Berglund via Lazarus
2018-07-25 16:32:51 UTC
Permalink
On Wed, 25 Jul 2018 11:47:06 -0400, Paul Breneman via Lazarus
Post by Paul Breneman via Lazarus
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.
--
Bo Berglund
Developer in Sweden

--
Paul Breneman via Lazarus
2018-07-25 16:39:38 UTC
Permalink
Post by Bo Berglund via Lazarus
On Wed, 25 Jul 2018 11:47:06 -0400, Paul Breneman via Lazarus
Post by Paul Breneman via Lazarus
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! :)
--
Bo Berglund via Lazarus
2018-07-25 16:47:51 UTC
Permalink
On Wed, 25 Jul 2018 11:47:06 -0400, Paul Breneman via Lazarus
Post by Paul Breneman via Lazarus
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

--
Paul Breneman via Lazarus
2018-07-25 17:07:10 UTC
Permalink
Post by Bo Berglund via Lazarus
On Wed, 25 Jul 2018 11:47:06 -0400, Paul Breneman via Lazarus
Post by Paul Breneman via Lazarus
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
--
Bo Berglund via Lazarus
2018-07-25 18:40:00 UTC
Permalink
On Wed, 25 Jul 2018 13:07:10 -0400, Paul Breneman via Lazarus
Post by Paul Breneman via Lazarus
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

--
Bo Berglund via Lazarus
2018-07-26 08:02:10 UTC
Permalink
On Wed, 25 Jul 2018 20:40:00 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
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

--
Sven Barth via Lazarus
2018-07-26 08:26:27 UTC
Permalink
Post by Bo Berglund via Lazarus
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.
Post by Bo Berglund via Lazarus
So I have NOT edited the code for any Win/Linux differences for
example, is that needed?
Maybe, depending on your program.
Post by Bo Berglund via Lazarus
For example in some console apps I have made also for both Windows and
{$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
Bo Berglund via Lazarus
2018-07-27 06:21:56 UTC
Permalink
On Thu, 26 Jul 2018 10:26:27 +0200, Sven Barth via Lazarus
Post by Sven Barth via Lazarus
Post by Bo Berglund via Lazarus
For example in some console apps I have made also for both Windows and
{$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

--
Bo Berglund via Lazarus
2018-07-27 17:58:07 UTC
Permalink
On Fri, 27 Jul 2018 08:21:56 +0200, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
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

--
R0b0t1 via Lazarus
2018-07-25 18:57:54 UTC
Permalink
https://wiki.gentoo.org/wiki/Project:Android

On Wed, Jul 25, 2018 at 7:04 AM, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
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
--
Bo Berglund via Lazarus
2018-07-25 20:10:07 UTC
Permalink
On Wed, 25 Jul 2018 13:57:54 -0500, R0b0t1 via Lazarus
Post by R0b0t1 via Lazarus
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)...
--
Bo Berglund
Developer in Sweden

--
R0b0t1 via Lazarus
2018-07-26 01:22:49 UTC
Permalink
On Wed, Jul 25, 2018 at 3:10 PM, Bo Berglund via Lazarus
Post by Bo Berglund via Lazarus
On Wed, 25 Jul 2018 13:57:54 -0500, R0b0t1 via Lazarus
Post by R0b0t1 via Lazarus
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
--
Loading...