Recent

Author Topic: unit not found (StdCtrls)  (Read 1600 times)

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
unit not found (StdCtrls)
« on: September 14, 2023, 01:47:53 pm »
In a project with multiple forms and units, I added a new form and tried to add the event Onshow from the Events tab. An error message appeared saying "unit not found: StdCtrls". I checked the paths and other form units. StdCtrls is in the uses clause of every form and the paths are the same. I did not change any path, nor added any package, so this error was strange, especially because I was able to compile and run the project. So I figured, what would happen if I change the uses clause by moving StdCtrls from the end of the list. That did the trick and I could add the OnShow event. This looks like a bug.

Error:
Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;

No error:
Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, StdCtrls, Forms, Controls, Graphics, Dialogs;

This is the first time I run into this error. I use Lazarus 2.2.6 on Debian Linux 12. The error so far only occurred when trying to add an event.
« Last Edit: October 01, 2023, 10:55:52 am by munair »
keep it simple

GAN

  • Sr. Member
  • ****
  • Posts: 367
Re: unit not found StdCtrls
« Reply #1 on: September 15, 2023, 04:38:12 am »
It is not a bug, the units are loaded (or initialized) from right to left.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

PascalDragon

  • Hero Member
  • *****
  • Posts: 5281
  • Compiler Developer
Re: unit not found StdCtrls
« Reply #2 on: September 17, 2023, 06:05:59 pm »
It is not a bug, the units are loaded (or initialized) from right to left.

This is about the IDE, not the compiler. And there might indeed be a bug regarding this.

In a project with multiple forms and units, I added a new form and tried to add the event Onshow from the Events tab. An error message appeared saying "unit not found: StdCtrls". I checked the paths and other form units. StdCtrls is in the uses clause of every form and the paths are the same. I did not change any path, nor added any package, so this error was strange, especially because I was able to compile and run the project. So I figured, what would happen if I change the uses clause by moving StdCtrls from the end of the list. That did the trick and I could add the OnShow event. This looks like a bug.

Can you provide a small, self contained test project that shows the issue and then create a bug report for that?

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: unit not found StdCtrls
« Reply #3 on: September 19, 2023, 05:08:44 pm »
Can you provide a small, self contained test project that shows the issue and then create a bug report for that?

With small test projects I have not been able to reproduce this behaviour yet. I will do more tests and get back here when I run into this issue again.
keep it simple

TRon

  • Hero Member
  • *****
  • Posts: 1852
Re: unit not found StdCtrls
« Reply #4 on: September 20, 2023, 07:11:30 am »
I just ran into a similar situation that the order of the units was messed up which resulted in the compiler throwing the error (3.0RC1).

Just like munair I seem unable to reproduce but can say I was experimenting with NOGUI and console application using a datamodule (with a non visual component). It is strange because I can't remember having ran into that before.

2 cents.

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: unit not found StdCtrls
« Reply #5 on: October 01, 2023, 10:55:27 am »
This error/problem is tied into Codetools. What I have found from the IDE behavior so far is that when I start the IDE, open the project and try to find a variable definition from the context menu -> [Find Declaration of ... Alt+Up], no error pops up.

Then, after I run/stop the project (debug disabled) and repeat the context menu procedure, Codetools throws an error that a unit was not found. The units "not found" so far are StdCtrls and Clipbrd, but they may be arbitrary.

Same behavior is observed with adding control events, as I described earlier; after starting the IDE and opening the project, adding events (by double clicking the control on the form) works fine. After running the project, the same error is thrown.

Despite the error, I can run and build the project. But Codetools makes editing the project cumbersome and adding events no longer works.
« Last Edit: October 01, 2023, 10:58:34 am by munair »
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: unit not found (StdCtrls)
« Reply #6 on: October 01, 2023, 12:30:07 pm »
There is no difference in behavior after running or building the project. Either way path definitions seem to be messed up.
keep it simple

cdbc

  • Hero Member
  • *****
  • Posts: 718
    • http://www.cdbc.dk
Re: unit not found (StdCtrls)
« Reply #7 on: October 01, 2023, 02:03:43 pm »
Hi
I had that exact problem once, it was a PITFA!
I even stood on my head before the laptop, ...nothing seemed to cure it.
It turned out to be a deeply buried "double free" in my code(not fpc/lazarus).
At the point, where I found it, my code was riddled(nothing else than) with "try-except LogLn; end" I even changed parts of the LCL, hunting it down...
What I'm saying is, it can be a teensy-weensy-tiny bit, that only shows its ugly head on spurious occasions, that tips the wagon.
So, it's time to go hunting and preferably show us the entire code, if possible.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6

d7_2_laz

  • Sr. Member
  • ****
  • Posts: 439
Re: unit not found (StdCtrls)
« Reply #8 on: October 01, 2023, 03:17:48 pm »
I'd sporadically (but not reproduceable) encountered the same (Laz. 3.0RC1 win x64), especially when i had - without having changed anything else - introduced into my form's unit something like:

Code: Pascal  [Select][+][-]
  1.   TEdit = class(StdCtrls.TEdit)
  2.    procedure WMEraseBkgnd(var Message: TLMEraseBkgnd); message LM_ERASEBKGND;
  3.   end;
for to expose a message. Compiler complaint: unit StdCtrls not found ...
Surprise ... the unit had uses:
Code: Pascal  [Select][+][-]
  1.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  2.   ComCtrls, StdCtrls,   ... and others ....
 
After having changed dummy-wise the "StdCtrls.TEdit" to some other unit qualifier a couple of times and back to StdCtrls again, finally it had been accepted ...

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: unit not found (StdCtrls)
« Reply #9 on: October 01, 2023, 03:32:24 pm »
So far, my particular case seems to be limited to Linux (Lazarus 2.2.6 on Debian 12 x64). There is no problem when I edit/run/build the same project with Lazarus 2.2.0 on Windows 7 x64. I will try Lazarus 2.2.6 on W7 as well.
keep it simple

munair

  • Hero Member
  • *****
  • Posts: 798
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: unit not found (StdCtrls)
« Reply #10 on: October 01, 2023, 04:05:45 pm »
It looks like - at least on Linux - the Lazarus IDE/Codetools has difficulty with the order of units in the uses clause. When I place e.g. Clipbrd between my own custom units, the error as described earlier pops up. When I place Clipbrd between the Lazarus units (and all other Lazarus units in the uses clause precede all custom units) no error occurs. I have not yet observed this behavior on Windows.
keep it simple

sfeinst

  • Full Member
  • ***
  • Posts: 220
Re: unit not found (StdCtrls)
« Reply #11 on: October 12, 2023, 01:45:47 am »
I have this same issue.  Running Debian Bookworm.  Lazarus is 2.2.6+dfsg2-2.  In my case, moving items around the uses clause doesn't seem to solve the problem.  At some point (it varies when it will hit), I can't change control names or double-click an event in the object inspector to tie a procedure to the event.  My only option is to close Lazarus and start it back up.  Then I'm good to go for a while before it happens again.  I'm starting to wonder if it is Debian's build of Lazarus and I should download debs from the Lazarus download page.

Haven't tried this yet since I'm in the middle of coding, didn't want to interrupt my setup.  But these constant restarts are getting old.

 

TinyPortal © 2005-2018