Recent

Author Topic: Compile to a tablet?  (Read 10884 times)

regressist

  • New Member
  • *
  • Posts: 18
Compile to a tablet?
« on: October 27, 2021, 02:18:35 pm »
Hi all,
I am sorry if my question is stupid and probably very wrong. My experience with Pascal is limited to programs like the ones in the very old Jensen, Wirth- Pascal User manual and report- 1978 (Yes, 78!), no graphics, no class, no make, etc. Sometimes I revamp it when I need to solve some problems which are too complex for some math packages.
I have successfully written a small program which makes some computations with integers, does not need any input or interactions, and has very little requirements in terms of ram, etc. During execution it writes on screen some numbers to show the status of the computation, at the end it just writes to a file some numbers. It runs on pc, BUT the problem is the CPU usage, if I want to find some solutions I need weeks and probably months. I do  not want to burn my PC. In absence for now of access to a powerful workstation or a mainframe I was thinking to use an old Samsung Galaxy tab, even though slower I would not care if it would die.
So the question is: is there any possibility to compile this program (it is only a basic program) to an .apk which in my dreams would need only to be tapped and starts the computation, again no interaction.
Please note that as an add-on I know nothing also of Android.
Thanks in advance to anybody will take the time to answer

Sergio

af0815

  • Hero Member
  • *****
  • Posts: 771
Re: Compile to a tablet?
« Reply #1 on: October 27, 2021, 02:46:14 pm »
It is not the easiest way. Normally nothing for a newbee

Docs for installing are here https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/docs in LAMW_Getting_Started.txt

Search for LAMW + Lazarus give more results.

BTW: A RasPi will also a cheap soloution - can run headless
regards
Andreas

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9686
  • FPC developer.
Re: Compile to a tablet?
« Reply #2 on: October 27, 2021, 02:48:18 pm »

BTW: A RasPi will also a cheap soloution - can run headless

Or any PC out of a dumpster will probably be both easier and faster.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3469
Re: Compile to a tablet?
« Reply #3 on: October 27, 2021, 03:45:11 pm »

BTW: A RasPi will also a cheap soloution - can run headless

Or any PC out of a dumpster will probably be both easier and faster.

Do any "cloud-based" computation services have off-peak rates? In any event, reading between the OP lines if this really is going to need lots of CPU time the first thing to do is to work out to what extent it can be split into threads (since just about every CPU now has multiple cores) or can be parallelised over a cluster (or real computers or VMs provided by AWS or whoever).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

y.ivanov

  • Sr. Member
  • ****
  • Posts: 306
Re: Compile to a tablet?
« Reply #4 on: October 27, 2021, 04:07:49 pm »
Although it is not "Compile" to a tablet, searching a time ago for a Pascal app for purely educational purposes, I found Pascal N-IDE. It is an interpreter and it can load/save scripts to the phone storage, so it is possible to transfer scripts from/to PC.

Еvaluated by me for nothing but for weird tests how it handles enumeration types, multi-dim arrays and things like that. It doesn't work well.

Very simple to use but probably it is completely worthless for computational intensive tasks. Not tested though.

engkin

  • Hero Member
  • *****
  • Posts: 2977
Re: Compile to a tablet?
« Reply #5 on: October 27, 2021, 05:30:03 pm »
Hi all,
I am sorry if my question is stupid and probably very wrong. My experience with Pascal is limited to programs like the ones in the very old Jensen, Wirth- Pascal User manual and report- 1978 (Yes, 78!), no graphics, no class, no make, etc. Sometimes I revamp it when I need to solve some problems which are too complex for some math packages.
I have successfully written a small program which makes some computations with integers, does not need any input or interactions, and has very little requirements in terms of ram, etc. During execution it writes on screen some numbers to show the status of the computation, at the end it just writes to a file some numbers. It runs on pc, BUT the problem is the CPU usage, if I want to find some solutions I need weeks and probably months. I do  not want to burn my PC. In absence for now of access to a powerful workstation or a mainframe I was thinking to use an old Samsung Galaxy tab, even though slower I would not care if it would die.
So the question is: is there any possibility to compile this program (it is only a basic program) to an .apk which in my dreams would need only to be tapped and starts the computation, again no interaction.
Please note that as an add-on I know nothing also of Android.
Thanks in advance to anybody will take the time to answer

Sergio

Hi Sergio,

Are you using Linux or Windows?
Which Galaxy tab do you have? Is it rooted?

Since you are not using any graphical interface, you don't need an apk file. Android includes a terminal. What you need is a cross compiler on your PC and a terminal emulator on your Galaxy. You program as usual on your computer, and when you think your code is ready you cross compile it to produce a version that works on your Galaxy.

Transfer that version to your tablet and run it. This step is a little tricky if you are not familiar with Linux and what you do depends on the Galaxy being rooted or not. In the most common situation,  you copy the program to a specific folder, change its mode to executable, and run it.

regressist

  • New Member
  • *
  • Posts: 18
Re: Compile to a tablet?
« Reply #6 on: October 27, 2021, 08:30:17 pm »

Hi Sergio,

Are you using Linux or Windows?
Which Galaxy tab do you have? Is it rooted?

Since you are not using any graphical interface, you don't need an apk file. Android includes a terminal. What you need is a cross compiler on your PC and a terminal emulator on your Galaxy. You program as usual on your computer, and when you think your code is ready you cross compile it to produce a version that works on your Galaxy.

Transfer that version to your tablet and run it. This step is a little tricky if you are not familiar with Linux and what you do depends on the Galaxy being rooted or not. In the most common situation,  you copy the program to a specific folder, change its mode to executable, and run it.

Hi and thank you for your reply, also to the others. I am using Windows, I do not know Linux, and the Galaxy is rooted, even though I did it blindly 3 years ago to install version 7 of Android, which now works quite bad, the whole process was a bit disappointing, poor outcome.
The first question would be which cross compiler is available? And the second is the hardest I guess, how can I run the terminal emulator? I remember vaguely that I was able to enter into a tool, TWRP ...

ojz0r

  • New Member
  • *
  • Posts: 43
Re: Compile to a tablet?
« Reply #7 on: October 27, 2021, 08:48:36 pm »
I have the FPC compiler installed in Termux on my android phone.
This is where i usually do all my (hobby) coding and then compile and run them in the Termux terminal, so no "native" apk.
Just trying to learn.

engkin

  • Hero Member
  • *****
  • Posts: 2977
Re: Compile to a tablet?
« Reply #8 on: October 27, 2021, 09:06:36 pm »
The first question would be which cross compiler is available?

On Windows I used to used Laz4android.
What version of Windows are you using?
What model number is your Galaxy?

And the second is the hardest I guess, how can I run the terminal emulator? I remember vaguely that I was able to enter into a tool, TWRP ...

For terminal emulator I used to use this one

For your purpose, the first difference between Windows command line and Android terminal is permission to run an app. The executable on Windows has exe extension, while on Linux it has no extension. If you copy an executable from your PC to Android you need to change its mode to make it executable using chmod:

chmod 755 ./yourFileName

I used to put my test files in /data/local/tmp/ folder, then change their mode, and run them

Unlike Windows, in Android/Linux terminal to run an executable located in the current directory you need to add a period and a slash ./ before the executable:
./test


I forgot to mention, if you have the drivers for your Galaxy installed on your Windows, you can use ADB (Android Debug Bridge) on your Windows to copy files, change their mode, and run them from within WIndows itself. Also, you can use an open source application called scrcpy to see your Galaxy on your Windows screen. ADB and scrcpy should help while working on your app if you prefer to use one screen/keyboard/mouse instead of switching back and forth between the two devices.

« Last Edit: October 27, 2021, 09:36:26 pm by engkin »

regressist

  • New Member
  • *
  • Posts: 18
Re: Compile to a tablet?
« Reply #9 on: October 27, 2021, 09:54:17 pm »

On Windows I used to used Laz4android.
What version of Windows are you using?
What model number is your Galaxy?

For terminal emulator I used to use this one

For your purpose, the first difference between Windows command line and Android terminal is permission to run an app. The executable on Windows has exe extension, while on Linux it has no extension. If you copy an executable from your PC to Android you need to change its mode to make it executable using chmod:

chmod 755 ./yourFileName

I used to put my test files in /data/local/tmp/ folder, then change their mode, and run them

Unlike Windows, in Android/Linux terminal to run an executable located in the current directory you need to add a period and a slash ./ before the executable:
./test

I forgot to mention, if you have the drivers for your Galaxy installed on your Windows, you can use ADB (Android Debug Bridge) on your Windows to copy files, change their mode, and run them from within WIndows itself. Also, you can use an open source application called scrcpy to see your Galaxy on your Windows screen. ADB and scrcpy should help while working on your app if you prefer to use one screen/keyboard/mouse instead of switching back and forth between the two devices.

The Galaxy is 10.1, I am using a virtual machine XP (VMWare) for Lazarus to avoid cluttering the PC.
I appreciate a lot the time you are wasting to answer to me, but I have to say that it's unlikely I will succeed, I know practically nothing of what you are saying and do not know where to start!! I will try of course, I like too much your solution...

MarkMLl

  • Hero Member
  • *****
  • Posts: 3469
Re: Compile to a tablet?
« Reply #10 on: October 27, 2021, 10:03:03 pm »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

engkin

  • Hero Member
  • *****
  • Posts: 2977
Re: Compile to a tablet?
« Reply #11 on: October 27, 2021, 11:52:04 pm »
I know practically nothing of what you are saying and do not know where to start!! I will try of course, I like too much your solution...

I would suggest you start with laz4android and see if it works on Windows xp.

You only need to be patient and when you get stuck don't hesitate to post your questions. The forums are full of friendly people.
« Last Edit: October 27, 2021, 11:54:26 pm by engkin »

y.ivanov

  • Sr. Member
  • ****
  • Posts: 306
Re: Compile to a tablet?
« Reply #12 on: October 28, 2021, 12:24:32 am »
I have the FPC compiler installed in Termux on my android phone.
This is where i usually do all my (hobby) coding and then compile and run them in the Termux terminal, so no "native" apk.
That's the beauty of the forum life!

Installed the Termux from the app store, then: Settings->Applications->Termux->Permissions, enabled the Storage permission.
In the Termux console:
Code: [Select]
$ pkg install clang
$ pkg install fp-compiler
$ termux-setup-storage
the last one creates a new directory in termux, ~/storage, which contains simlinks to /storage/emulated/0 and can be accessed by a standard gui file manager.

Wrote 1.pas with nano (text editor):
Code: Pascal  [Select][+][-]
  1. begin
  2.   writeln('hello!');
  3. end.

And then:
Code: [Select]
$ fpc 1.pas
$ ./1
hello!
Just simple as that! It is just Bluetooth keyboard missing.

Thanks ojz0r!

regressist

  • New Member
  • *
  • Posts: 18
Re: Compile to a tablet?
« Reply #13 on: October 28, 2021, 10:44:42 am »

I would suggest you start with laz4android and see if it works on Windows xp.

You only need to be patient and when you get stuck don't hesitate to post your questions. The forums are full of friendly people.
[/quote]

Thank you, yes it works, it's like the lazarus-2.0.12-fpc-3.2.0-win32 with which I compiled my program. But the result is the same, just an  *.exe, I thought it would come out with a linux/android executable. I did not find any menu to have an android output (surely I'm wrong on this)

S

engkin

  • Hero Member
  • *****
  • Posts: 2977
Re: Compile to a tablet?
« Reply #14 on: October 28, 2021, 12:25:17 pm »
Thank you, yes it works, it's like the lazarus-2.0.12-fpc-3.2.0-win32 with which I compiled my program. But the result is the same, just an  *.exe, I thought it would come out with a linux/android executable. I did not find any menu to have an android output (surely I'm wrong on this)

Yes, by default, it gives an exe file. You can change that by changing the target OS to Android, and target CPU to Arm. Both are in the Project Options window. You can open this window from the main menu under Project, or using CTRL+Shift+F11 key shortcut if I recall correctly.

I am not by a computer now, I'll try to post a screenshot later if you did not find them.

 

TinyPortal © 2005-2018