Lazarus

Using the Lazarus IDE => Options => Topic started by: sporex on May 20, 2022, 10:27:04 am

Title: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 10:27:04 am
Pls.help,
I have installed Laz v2.0.10 on a RPi with Debian 11 (bullseye) following this tutorial:
 https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi  (https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi)

Now I want to test the installed IDE for this particular setup:
The directory for the source files is on a windows share on a different machine and properly mounted with all required access rights.
When I open a very simple test.pas file from this source directory and try to compile it, the following will happen:

- the IDE reports "BEGIN expected but end of file found"
- the test.pas file on the windows share still exists, but the content is deleted (0byte)
- the backup, lib, test.lpi, test.lps are created in the shared folder. So it cannot be a problem of access rights

When I do the same test with a folder on the local file system, everything works.
And btw, I had the same configuration (source on shared directory) with Jessie and an older version of lazarus.

I suppose I need to change something in the Tools|Options settings, but what?

Thank you for advice and kind regards
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 10:45:59 am
Use the file ** command to check what the line endings are.

** That's a standard unix command. Whatever the RPi people would like to call it, you're running a remix of the Debian Linux distribution, which roughly speaking is "a unix".

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 10:59:25 am
This is the result of file ** before attempting to compile:
 
Code: Pascal  [Select][+][-]
  1.   test0.pas: ASCII text, with CRLF line terminators

And this is after attempting to compile:
Code: Pascal  [Select][+][-]
  1.   backup:    directory
  2. lib:       directory
  3. test0.lpi: XML 1.0 document, ASCII text
  4. test0.lps: XML 1.0 document, ASCII text
  5. test0.pas: empty
  6.  
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 11:05:53 am
And this is what I get for the executable when I successfully compile on the local file system:

Code: Pascal  [Select][+][-]
  1.  test0:     ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, with debug_info, not stripped  
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 11:08:25 am
You might need to find a text editor that saves files with unix-style line endings. I /thought/ that the compiler was tolerant of variations there.

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 12:13:08 pm
You might need to find a text editor that saves files with unix-style line endings. I /thought/ that the compiler was tolerant of variations there.

MarkMLl

But this cannot be the reason for the problem because the source file on the local file system has the same format:

Code: Pascal  [Select][+][-]
  1.  test0.pas: ASCII text, with CRLF line terminators  

this test0.pas was written with the source editor on the windows LAZ, stored to /NAS and then transferred to the local file system of the RPi, and it compiles.
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 12:32:23 pm
Hmm. Going back through the thread: I used ** to indicate a footnote and assumed you would understand that you had to enter something like

Code: [Select]
file test.pas

Is it /really/ showing test.pas empty after compilation?

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 12:54:25 pm

Really, really. This is before compilation:
Code: Pascal  [Select][+][-]
  1. pi@DEB11IDE:/NAS/TEST $ file ./test0.pas
  2. ./test0.pas: ASCII text, with CRLF line terminators

And this is afterwards:
Code: Pascal  [Select][+][-]
  1. pi@DEB11IDE:/NAS/TEST $ file ./test0.pas
  2. ./test0.pas: empty

And this is the source on the local file system that compiles:
Code: Pascal  [Select][+][-]
  1.  pi@DEB11IDE:~/fpcsrc/TEST $ file ./test0.pas
  2. ./test0.pas: ASCII text, with CRLF line terminators


Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 01:11:18 pm
Really, really odd :-|

Presumably you're building using the full IDE... what happens if instead you apply lazbuild to the .lpi (Lazarus project information) file?

I must say that mapping stuff like that wouldn't be my first choice: I usually use Subversion as the common point. Any idea what protocol is being used (check mount command output)?

Edited: incorrectly referred to .lpr file.

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 02:02:01 pm
Really, really odd :-|
Presumably you're building using the full IDE... what happens if instead you apply lazbuild to the lpr (Lazarus project) file?
I must say that mapping stuff like that wouldn't be my first choice: I usually use Subversion as the common point. Any idea what protocol is being used (check mount command output)?

MarkMLl

The mount result gives me this (for the share):
Code: Pascal  [Select][+][-]
  1.  //192.168.2.126/PINAS/RASPI on /NAS type cifs (rw,relatime,vers=2.1,cache=strict,username=pi,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.2.126,file_mode=0777,dir_mode=0777,soft,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,bsize=1048576,echo_interval=60,actimeo=1)

And this is what I get for the Jessie IDE (where all is ok)
Code: Pascal  [Select][+][-]
  1.  //192.168.2.126/PINAS/RASPI on /NAS type cifs (rw,relatime,vers=2.1,sec=ntlmssp,cache=strict,username=pi,domain=P1W764,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.2.126,file_mode=0755,dir_mode=0755,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)

You know that I am not so deeply involved in the internals of Lazarus stuff but what I did so far was:
- create /NAS/TEST/test_abc on the LAZ_WIN IDE
- trying to conpile (Ctrl-F9) --> failed
- trying to Build (Shift-F9) --> failed

So I am loosing hope.
I can only confirm that I have a SD card image with Debian 8 (Jessie) and LAZ 1.2.4.dfsg2-1 where all this has worked perfectly for years now.
To compile to/from the win share is very convenient because I can edit under LAZ-WIN and compile/debug under LINUX arm and get the executable right back to the archive from where I can redistribute it to many other RPi units in the field.
Unfortunately I am forced to upgrade all RPi units now to Debian 11 (Jessie is end of life) and it seems that some of the executables that I create with the Jessie IDE do not run on the upgraded Bullseye units.
The majority of my applications are "SimpleProgram" without GUI. Only one uses GUI
I have to say that I am not interested to always have the most recent release of LAZ and that "compiling the IDE" "cross compiling" and such stuff is beyond my knowledge.
So my first choice would be to have a simple way to install version 1.2.4.dfsg2-1 (apt-get install ...) on the Bullseye image, provided that it creates executables that are running. 
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 02:10:15 pm
- trying to Build (Shift-F9) --> failed

...

Unfortunately I am forced to upgrade all RPi units now to Debian 11 (Jessie is end of life) and it seems that some of the executables that I create with the Jessie IDE do not run on the upgraded Bullseye units.

...

So my first choice would be to have a simple way to install version 1.2.4.dfsg2-1 (apt-get install ...) on the Bullseye image, provided that it creates executables that are running.

a) What happens if you use Lazbuild?

b) It would be worth raising failing apps as a separate thread.

c) Look back through the forum for discussion on installing Lazarus on an RPi. I for one normally build from source, but I believe that the consensus is that using the distro-provided apt is the least-good way because of the delay to getting bugfixes etc. into it.

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 02:26:31 pm
- trying to Build (Shift-F9) --> failed

...

Unfortunately I am forced to upgrade all RPi units now to Debian 11 (Jessie is end of life) and it seems that some of the executables that I create with the Jessie IDE do not run on the upgraded Bullseye units.

a) What happens if you use Lazbuild?

b) It would be worth raising failing apps as a separate thread.

c) Look back through the forum for discussion on installing Lazarus on an RPi. I for one normally build from source, but I believe that the consensus is that using the distro-provided apt is the least-good way because of the delay to getting bugfixes etc. into it.

MarkMLl
First of all, I appreciate your help.
Concerning a) : do you mean I should use Tools|Build Lazarus with Profile Normal IDE ?
Concerning b) : do you mean that apps compiled on Jessie and 1.2.4 dfsg2-1 should normally work with Bullseye?
Concerning c) : I will keep on the struggle with this

Thanks a lot
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 03:50:01 pm
a) You have a program called lazbuild. Use it.

b) Generally speaking, yes. Otherwise it's of general interest to know what's going on.

c) Well done.

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: PascalDragon on May 20, 2022, 03:58:18 pm
Concerning a) : do you mean I should use Tools|Build Lazarus with Profile Normal IDE ?

No, MarkMLI means the lazbuild utility provided with Lazarus which allows to build a Lazarus project from the command line.

But lets get simpler, just to check whether compilation by itself works: create a new unit on your share with a simple program (just something that does a Writeln('Hello World')) and compile that manually using fpc theprogram.pas. Does this work correctly? What was the output of FPC if it didn't?
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 06:16:37 pm
Without wanting to sound condescending but to make things absolutely clear: lazbuild" and "fpc" are programs that you will need to invoke in a shell session. You should be able to either cut-and-paste or redirect the output so that you can relay it to us.

Please do not oblige me to refer to that as a terminal emulator, command prompt or anything similar: there are depths to which I am reluctant to stoop :-)

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 09:36:26 pm
No, MarkMLI means the lazbuild utility provided with Lazarus which allows to build a Lazarus project from the command line.

But lets get simpler, just to check whether compilation by itself works: create a new unit on your share with a simple program (just something that does a Writeln('Hello World')) and compile that manually using fpc theprogram.pas. Does this work correctly? What was the output of FPC if it didn't?
[/quote]

Yes, that one works:

Code: Pascal  [Select][+][-]
  1. root@DEB11IDE:/NAS/TEST# fpc ./test0.pas
  2. Free Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for aarch64
  3. Copyright (c) 1993-2020 by Florian Klaempfl and others
  4. Target OS: Linux for AArch64
  5. Compiling ./test0.pas
  6. test0.pas(13,6) Warning: Variable "i" does not seem to be initialized
  7. Assembling test
  8. Linking test0
  9. 17 lines compiled, 1.8 sec
  10. 1 warning(s) issued
  11.  
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 09:40:04 pm
And this is the executable:

Code: Pascal  [Select][+][-]
  1.  root@DEB11IDE:/NAS/TEST# file ./test0
  2. ./test0: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, stripped
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 20, 2022, 09:43:14 pm
And those are the files created in the shared directory:

Code: Pascal  [Select][+][-]
  1.  root@DEB11IDE:/NAS/TEST# ls -l
  2. total 573
  3. -rwxrwxrwx 1 pi pi 577296 May 20 20:32 test0
  4. -rwxrwxrwx 1 pi pi   4696 May 20 20:32 test0.o
  5. -rwxrwxrwx 1 pi pi    151 May 20 09:43 test0.pas
  6.  
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on May 20, 2022, 09:44:27 pm
I'm uncomfortable to see you running as root. This is not the recommended way of working, it can mess up GUI-oriented software (including introducing security vulnerabilities) and also have an impact on remote file mounts.

(And please fix your broken formatting, and you might find the "Modify" button useful when you want to add e.g. a list of files).

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: PascalDragon on May 21, 2022, 04:59:03 pm
Yes, that one works:

Okay, great. Next step: would you please share the command line that Lazarus generates for your project, maybe that will give a hint what goes wrong? You can get that in the project's settings using the button “Show settings” (or similar, I'm using the German version) and then the content of the tab “Command line arguments” (or similar).
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on May 21, 2022, 07:10:44 pm
Thank you for beeing available to help.

I was running the IDE from a terminal window.
Then I have set the project_options|verbosity to "show all"
And have copied the terminal output to the file cpl_msg1.txt (this is compiling the source from the share)

Next I did the same but compiling the source from the local file system, the output is in cpl_msg2.txt
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on June 04, 2022, 11:31:12 am
After being discouraged for a while I have resumed trying to compile from the shared folder.
What I found out is this:

-1) I create the source file test.pas and make a copy test.bak
-2) I try to compile test.pas and I am getting "begin expected but end of file found" and test.pas on the share is 0byte
-3) Then I copy test.bak > test.pas and try to recompile
-4) I get "source file has changed on disk," and I chose "reload checked file from disk"
- And now it compiles

After step-2) I get the following files in the shared folder /src

Code: Pascal  [Select][+][-]
  1. - /src/backup/test.pas
  2. - /src/lib/aarch64-linux/test.compiled
  3. - /src/test.lpi
  4. - /src/test.lps  

After step -4) I get additionally:
Code: Pascal  [Select][+][-]
  1. - /src/lib/aarch64-linux/test.o
and of course the executable /src/test

I suppose there must be any setting in the IDE options that must be changed.
Only what is it? I made no changes to the default config.
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on June 04, 2022, 12:11:55 pm
So going back through the thread:

a) You're using CIFS.

b) Are you still running on the client as root?

c) Have you tried using Lazbuild yet?

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on June 04, 2022, 12:37:31 pm
Hello Mark
thank you for remembering this topic

a) yes I am using cifs

b) no, this time i ran it as user pi

c)
Code: Pascal  [Select][+][-]
  1. lazbuild -B /NAS/TEST/test1.pas
  2. Error: (lazbuild) don't know how to build: /NAS/TEST/test.pas  
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on June 04, 2022, 12:43:42 pm
Lazbuild expects a .lpi ("Lazarus Project Information").

If you were building a simple "Hello, World!" console program which didn't have a .lpi you'd simply use fpc to compile the .pas... I've just done that over a CIFS share from a PC client and am about to try Lazarus.

Very slightly later: Definitely no problem using Lazarus 2.2.0 with FPC 3.2.2.

Client system running Debian "Stable" (i.e. the OS that yours is derived from) but x86_64 rather than ARM... I'd not expect that to be an issue.

Running mount describes the connection as

Code: [Select]
//192.168.0.72/guest on /home/markMLl/srv/gooey.guest type cifs (rw,nosuid,nodev,relatime,vers=2.0,cache=strict,username=guest,domain=XXXXXXXX,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.0.72,file_mode=0755,dir_mode=0755,soft,nounix,mapposix,noperm,rsize=65536,wsize=65536,echo_interval=60,actimeo=1,user=markMLl)

derived from this in .etc.fstab

Code: [Select]
//192.168.0.72/guest    /home/markMLl/srv/gooey.guest   cifs    noauto,user,username=guest,guest,workgroup=XXXXXXXX,vers=2.0,noperm     0       0

One thing I'd emphasise is that I accessed the project from a fixed mountpoint off my home directory, rather than via a desktop file manager or something under the "Places" list of a save-as dialogue or similar... the naming there might depend on what widget set's been used to build your IDE.

I don't think this is an IDE issue, it's down to either how your OS is setting up mounts, or the configuration and capabilities of your NAS.

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on June 04, 2022, 01:22:14 pm
Alright, then I will have to inquire the mount options. This is mine:
Code: Pascal  [Select][+][-]
  1. //192.168.2.126/PINAS/RASPI on /NAS type cifs (rw,relatime,vers=2.1,cache=strict,username=pi,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.2.126,file_mode=0777,dir_mode=0777,soft,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,bsize=1048576,echo_interval=60,actimeo=1)

And fstab is like that:
Code: Pascal  [Select][+][-]
  1. //192.168.2.126/PINAS/RASPI     /NAS    cifs    credentials=/etc/.credentials,uid=pi,gid=pi,file_mode=0777,dir_mode=0777

I will try to mount the share manually and get back with the result.
THX Mark
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on June 04, 2022, 01:44:17 pm
Getting mount options right- particularly for networked shares and most particularly for SMB/CIFS- is arguably more difficult than it needs to be. But the bottom line is that all of the possible options are there for a reason.

I speculate that /if/ your NAS were based on "a unix" and /if/ you could get a shell session you'd find (using ls -i) that when Lazarus saved a file it first renamed the original to .bak or similar and then created a new one, and that under certain circumstances the client system is seeing the new one cached before anything has actually been written to it. That rename-create is longstanding unix doctrine with the intention of limiting the extent to which a less-privileged user can overwrite the work of a more-privileged one, and can be contrasted with the Windows convention of doing a copy-overwrite. If that's what's really happening, then it's a NAS (or possibly client library) bug.

You /might/ find that telling the IDE to not create a backup (Tools -> Options -> Environment -> Backup) changes that behaviour: arguably, if it's told to create no backup then it should be overwriting the same file in-situ rather than creating a new one.

MarkMLl
Title: Re: Raspberry with source directory on a windows share
Post by: sporex on June 04, 2022, 11:32:06 pm
Good evening Mark,
I will give up.
What I am going to do is:
- create a debian11 32 bit images for the units for which I want to roll out the SW
- use the debian8 image that I have for the IDE in order to maintain/modify the existing applications that I am distributing to the units
- I suppose there will be no hitch (jessie/bullseye) as long as it's 32bit
My only concern is that jessie is end-of-life and only compatible with RPi up to Ver.3B (not Ver.3B+) and the hardware will also be phased-out by 2023 as I learn
Title: Re: Raspberry with source directory on a windows share
Post by: MarkMLl on June 05, 2022, 09:30:46 am
Good evening Mark,
I will give up.
What I am going to do is:
- create a debian11 32 bit images for the units for which I want to roll out the SW
- use the debian8 image that I have for the IDE in order to maintain/modify the existing applications that I am distributing to the units
- I suppose there will be no hitch (jessie/bullseye) as long as it's 32bit
My only concern is that jessie is end-of-life and only compatible with RPi up to Ver.3B (not Ver.3B+) and the hardware will also be phased-out by 2023 as I learn

In any event, always test thoroughly. There's always a risk of incompatibility at the library level.

Otherwise, set up a local Subversion etc. server. I think one's available as a Debian package, but otherwise it's easy enough to build particularly if you stick to the native svn protocol rather than trying to integrate with Apache.

Jessie really is getting on a bit by now, and isn't one of those releases for which there were compelling reasons to not upgrade: I'd cite Lenny as being one of those, since some targets were either dropped immediately afterwards, or their quality dropped as people lost interest (SPARC as a particular example). I've had some degree of success with in-situ upgrades, but I usually find redoing from scratch fairly painless since for many years I've been running a script which logs what gets installed manually. See https://github.com/MarkMLl/installed-package-list

MarkMLl
TinyPortal © 2005-2018