[fpc-pascal] Lazarus complains that it cannot find a dependency, why?

Bo Berglund bo.berglund at gmail.com
Tue Sep 1 22:46:55 CEST 2020


On Tue, 01 Sep 2020 21:07:56 +0200, Bo Berglund via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>I get an error message when building a project after updating from SVN
>to get the sources that build fine on another RPi4 identical in
>configuration.
>
>"Fatal: Cannot find LazSerial used by RemoteIO. Check if package
>LazSerialPort is in the dependencies."
>
>The LazSerial dependency has been *removed*, that was the whole point
>of this excercise.
>There is no longer any mention in the source files of lazserial and I
>have removed the dependencies for LazSerial in the project inspector.
>
>Where can Lazarus have stored this bogus information?
>
>In Project inspector are only 3 items:
>Files
>  SerialTest.lpr
>  formmain.pas
>Required packages:
>  LCL
>
>I have even searched the files in the project for LazSerial and it
>only finds the word in comments....

Further debugging leads to the following:

1) I deleted the lib dir below the project so that Lazarus will
recompile everything.

2) Now Lazarus succeeds in building the application!
So there must have been some artifact left in the old lib dir from
earlier tests.

3) But when I run it, it disappears when I use the Open Comm button,
which is opening the serial port for communications!

4) So I stepped through the code below the button and reached this
after the serial commands actually completed successfully:
This is where the read thread is created and started:

  if Assigned(FOnRxData) then
  begin
    FReadThread := TComPortReadThread.Create(true); //<= Exception
    FReadThread.Owner := Self;
    FReadThread.MustDie := false;
    FReadThread.ReadPacketSize := FReadPacketSize;
    FReadThread.ReadTimeout := (FReadThread.ReadPacketSize * 10000)
div FBaudRate + 1;
    FReadThread.FreeOnTerminate := false;
    FReadThread.Start;
  end;


The error message that pops up on the first line in the block is this:

|------------------------------------------------------------|
| Debugger exception notification                            |
|------------------------------------------------------------|
| Project SerialTest raised exception class 'RunError(232)'. |
| At address 6B                                              |
|------------------------------------------------------------|

Note that the thread type is declared like this:

  TComPortReadThread=class(TThread)

So it is using TThread, which AFAIK is a general type of class and not
from LazSerial.

So the TThread creation is now throwing an exception whereas with the
LazSerial in the dependencies it did not..

STRANGE "SOLUTION", BUT WHY?
----------------------------
So even though I am not really using *anything* in LazSerial I added
LazSerialPort back to the dependencies and rebuilt the application.
Now the thread creation does no longer show any such exception!
And the application runs properly.

But I REALLY do not want to specify LazSerialPort as a dependency when
it is the point of my work to *remove* LazSerial and Synapse from the
project.

What is going on and how can I find where it really goes astray?
And what can LazSerial bring into this?

-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list