BTW: A RasPi will also a cheap soloution - can run headless
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.
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.
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 ...
On Windows I used to used Laz4android (https://sourceforge.net/projects/laz4android/).
What version of Windows are you using?
What model number is your Galaxy?
For terminal emulator I used to use this one (https://play.google.com/store/apps/details?id=jackpal.androidterm)
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.
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 have the FPC compiler installed in Termux on my android phone.That's the beauty of the forum life!
This is where i usually do all my (hobby) coding and then compile and run them in the Termux terminal, so no "native" apk.
$ 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.$ fpc 1.pas
$ ./1
hello!
Just simple as that! It is just Bluetooth keyboard missing. 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.Done (thanks). Surprisingly upon compilation I get an error on the 2nd last line [error while linking]
I am not by a computer now, I'll try to post a screenshot later if you did not find them.
Done (thanks). Surprisingly upon compilation I get an error on the 2nd last line [error while linking]
writeln(namefile,'Total solutions: ' , Nsoluzioni);
I am just writing in namefile: Total solutions nnn
And an identical command is written before, without any problem.
namefile is output.txt
In the meantime I also installed on the Galaxy your suggested Terminal emulator. It seems to work but touch wood because the OS is not performing well in general, it was probably a mistake to switch to this non-native OS.
Note: when you are fed up of supporting just say that, I do not want to disturb you too much!
@engkin, @regressist
Wouldn't it be much simpler just by installing Termux+clang+fp-compiler on the tablet?
No need for Android NDK, laz4android, etc. Just a text editor on the PC and USB cable to transfer the source files to the device.
It seems to work but touch wood because the OS is not performing well in general, it was probably a mistake to switch to this non-native OS.
Exactly what I'm writing about ... I've installed Termux+clang+fpc in a matter of minutes. Making my first apk with laz4android, LAMW, Android SDK+NDK took me days and several gigs on my HD. And then we should introduce OP to the Android bridges et al. Much, much steeper IMHO.@engkin, @regressist
Wouldn't it be much simpler just by installing Termux+clang+fp-compiler on the tablet?
No need for Android NDK, laz4android, etc. Just a text editor on the PC and USB cable to transfer the source files to the device.
I don't think either way is simpler. If you are comfortable using Linux or fpc directly you might prefer using Termux. If you are a Windows person or used to Lazarus, then you might prefer Laz4android.
In both cases you have to set the environment up.
No, no APK, just an executable for the terminal.Sorry, my error. I presumed *.apk (laz4android+LAMW) vs native executable (Termux+fpc).
But wait, did you produce an APK using Termux?No. Considering all additional stuff needed I didn't even think its possible.
Change the target OS to Android, CPU to Arm, and Target processor to ARMV7A
If you try to compile, you'll see a similar error. When you check the messages, the linker was unable to find one of the files, named: crtbegin_dynamic.o. This file comes with Android NDK. There are a few copies for each Android API version depending on the target processor.
To save you from needing to install the NDK, I'll make a guess and attach a zip file with the needed files. Expand the compressed file and point the test project to it using:
Compiler Options - Paths - LibrariesNote: when you are fed up of supporting just say that, I do not want to disturb you too much!
Don't worry about it.
To the guy who was asking about the nonnative OS, the Galaxy 10 (and also Toshiba with the AT100, in agreement I guess) after version 4.4 stopped upgrading very deceptively I believe since the hw was still good, they want us to buy a new tablet every other year. So someone suggested me after a few years to install a new version not from Samsung, I have now Android 7, but handicapped, it works only partially, e.g. the browser crashes, and I am not able to transfer large files to the pc. But for this which is only a few KB I could use even bluetooth (I hope)
I was the gentleman who was trying to help by finding that out. Refer to me as "guy" if you like, but I don't...Hi,
The major reason I was asking was because I was trying to fond out whether you thought that by rooting the tablet it was now "non-native". Or alternatively you were referring to the way you were driving Lazarus: your phrasing was a bit vague.
OK, this isn't really the place to discuss the care and feeding of Androids, but can you remember what you used: CyanogenMod or some derivative? I've been through this with a rather less prominent brand and ended up with CyanogenMod 13 (? Android 6.0.1) tailored for the specific "phablet" concerned, most of the stuff works and it's certainly good enough to be a useful development tool.
MarkMLl
Done, thanks a lot. Now I have a file without extension which I suppose is the executable.
I suppose I have to transfer it to the tablet, chmod like you said before and run. I do it only when you say that because I am afraid to make mistakes on the tablet, and there I would be lost, I do not have a virtual machine to start again
Yes, that file is the executable. There is nothing to worry about, any mistakes will not cause any major problem. Simply it either works or it does not. In the latter case, it might give a message explaining why it would not run.
Are you familiar with a way to transfer files between your Galaxy and your PC?
but even though I do not follow that page from 3 years and might have been fixed, I do not suggest you to install it.
but even though I do not follow that page from 3 years and might have been fixed, I do not suggest you to install it.I wouldn't dream of it for a moment. I was trying to find out what you were on about so that we could collectively help you
Thank you for asking. Your question lead him to provide a link that included the model number, Samsung GT-P7510, which helped pinpoint the exact CPU, Cortex-A9 and using ARMv7-A should be the correct instruction set.
This certainly shouldn't be a killer, and I would urge you to watch out for late responses (it's a weekend, so there might not be as much activity here as normal).
In the worst case you might end up having to install something like Termux anyway, simply to allow you to run chmod or whatever is needed... that should also allow you to use e.g. sftp which doesn't mess around with file permissions in transit.
The fact that people (myself included) have run the compiler successfully on the target system using Termux suggests that this is solvable, allowing you to develop comfortably on a host PC.
MarkMLl
I am able to transfer files (probably only small size but for me it's enough). BUT I am not allowed to change permissions for the file; I remember that when we changed the os (actually to 5 and later on to 7) we rooted it but later on for some reasons in the various attempts to improve the poor performances sometimes I got some messages that I was not a superuser or similar. There is a SuperSU application installed, which I probably used.
This is normal for Android. To control permissions, each apk application is run under a different "user" account. When you grant an application some permission, like access to your GPS location, you are giving its "user" account that permission.
On a rooted device, each account/app can request a superuser power. As a result you get a pop-up window asking you if you would like to allow the app to have superuser power. Typically on Android this window will disappear, if you don't respond, within 10 or 15 seconds rejecting the request. This detail depends on which Superuser app you have.
Test chmod again but this time request superuser power. You do that by typing su:
su chmod 755 ./yourFileName
Or su alone.
Not at all frustrating. I hope you're not too offended when I have to remind everybody that you're an admitted non-expert :-)
As I've said (but not necessarily in this thread) I've played with FPC running directly on an x86_64-based tablet using Termux in the past, and just to check that the basics still worked I loaded Termux onto my old development phablet a few days ago and was able to ssh into it (i.e. get a shell over a network connection) which implies sftp (file transfer) should also work. The implication of that is that FPC should run on an Android device itself and be controllable from a desktop computer, but something sophisticated like Lazarus might not because of the threads library problem (unless it's been fixed over the last three years, but that is related to the Android architecture rather than being directly fixable by either the Termux or FPC/Lazarus developers).
MarkMLl
Thanks. When I tried su chmod 755 ./FileName I had a pop-up and pushed granted, on the display I got
tmp-mksh: 755: not found
Then I tried su alone and got #, then typed chmod 755 ./file , I got no message but upon ls -al the rights of the file are not changed and if I type the name of the file I get
tmp-mksh:filename: not found
Yes, the name of the file alone will not work, unlike Windows. You need to put period slash ./ before it's name.
Yes, the name of the file alone will not work, unlike Windows. You need to put period slash ./ before it's name.
Unfortunately I will not be around a computer for some hours. As soon as I get a chance I'll try it on my side and give you a more accurate step.
At least now we know your device is rooted. :)
Considering what Mark said, I've just performed the following steps with Termux on my phone (it is not rooted):Not at all frustrating. I hope you're not too offended when I have to remind everybody that you're an admitted non-expert :-)
As I've said (but not necessarily in this thread) I've played with FPC running directly on an x86_64-based tablet using Termux in the past, and just to check that the basics still worked I loaded Termux onto my old development phablet a few days ago and was able to ssh into it (i.e. get a shell over a network connection) which implies sftp (file transfer) should also work. The implication of that is that FPC should run on an Android device itself and be controllable from a desktop computer, but something sophisticated like Lazarus might not because of the threads library problem (unless it's been fixed over the last three years, but that is related to the Android architecture rather than being directly fixable by either the Termux or FPC/Lazarus developers).
MarkMLl
Thank you Mark, anyway I do not understand practically one single sentence of what you wrote!!
Anyway now I think I am SU from what I wrote above
The thing is that the copied files will have the same owner as the user who started sshd, namely u0_a322. Thus you don't need root permissions to execute:i.e. to mark it as executable.
$ chmod +x binaryfile
Yes, the name of the file alone will not work, unlike Windows. You need to put period slash ./ before it's name.
Unfortunately I will not be around a computer for some hours. As soon as I get a chance I'll try it on my side and give you a more accurate step.
At least now we know your device is rooted. :)
Try to put the file in:
/data/local/tmp
And change its execution rights there.
This certainly shouldn't be a killer, and I would urge you to watch out for late responses (it's a weekend, so there might not be as much activity here as normal).
In the worst case you might end up having to install something like Termux anyway, simply to allow you to run chmod or whatever is needed... that should also allow you to use e.g. sftp which doesn't mess around with file permissions in transit.
The fact that people (myself included) have run the compiler successfully on the target system using Termux suggests that this is solvable, allowing you to develop comfortably on a host PC.
MarkMLl
Are you saying that with Termux I could take the precompiled file and change the execution rights without being root?
Are you saying that with Termux I could take the precompiled file and change the execution rights without being root?
I quoted a message which said that explicitly earlier, and I've previously said that sftp preserved permissions. Why- have you tried it and found it didn't work? >:-)
Sorry to sound like a grouch, but I've got things to do and limited daylight to do them.
I've just checked VERY briefly, and if I run sftp on an Android "Phablet" to get a file from a local PC the *user's* rwx rights are preserved, but the group and other rights are masked out. However I was able to chmod the file to 777 without having to do anything special (i.e. no sudo etc.).
Note that I said VERY briefly there. I'd normally log into the device using ssh so that I had a decent keyboard and screen on the PC, but I need to refresh my memory of how to do it.
Note also that permission handling could possibly be changed by (the Linux kernel that is part of) different versions of Android.
MarkMLl
Please do NOT waste your time to reply, I will monitor the page every while in case someone is willing to reply to these questions:
1) which tools should I use to transfer the file (on pc virtual machines, XP or Vista; termux I guess on android)
2) can I do this via usb cable (I mean without connecting the VM to internet which I can not do)?
3) is this feasible without being an expert?
1) which tools should I use to transfer the file (on pc virtual machines, XP or Vista; termux I guess on android)
2) can I do this via usb cable (I mean without connecting the VM to internet which I can not do)?
3) is this feasible without being an expert?
Mark thanks a lot for the long explanation, I will try to understand it, even though I am not happy on installing a tool in the pc (and the virtual machines can not go on internet...). I will see now if I can do it also on my new phone with the same steps... I will let you know if I manage to increase the array of devices running this stuff.