Recent

Author Topic: Lazarus IDE problem?  (Read 1962 times)

BrunoK

  • Hero Member
  • *****
  • Posts: 763
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #15 on: December 04, 2025, 03:47:36 pm »
These are my steps:
- etc ...

 These are my steps:
- Windows 10, 64-bit IDE (Laz/main + fpc 3.2.2)
- IDE from yesterday's git, clean rebuild of the IDE with
  -MObjFPC -Scghi -O1 -OoREGVAR
  -gw3 -gl -Xg  -WG-
  Target dir $(ConfDir)\
 I dont think those points are important and I do a clean of the units by deleting the $(ConfDir)\units dir.
 
Enter lazarus
- The last project gets shown.
- Project / New project ... / Application
 - Now have Unit1 shown.
 - Touch Unit1, add a space before 'unit unit1;'

- Project / New project ... / Application
 - Asks : Save changes to project project1?
 - Answer : Yes
 - Proposed : project1, I accept (because there is no project1 in the proposed folder)
 - Proposed : unit1, I put unit2 as .pas filename.
 - Here I have the new project, with an empty form.

- I decide to reload the prior project that I just saved above
 - Project / Recent project, the first one that comes.
 - Now I see unit2 that I specified above
 - Run F9 (it'll compile) maybe offering to debug ...
 - But project1.lpr(13,10) Error: Cannot find Unit1 used by project1 of the Project Inspector.
 - When I saved the form as unit2, it didn't correct the project1 replacing unit1 by unit2.
 
 If you dont get the same result as me, I go back to the programmer's asylum and drop the case. Thanks.

wp

  • Hero Member
  • *****
  • Posts: 13336
Re: Lazarus IDE problem?
« Reply #16 on: December 04, 2025, 04:55:29 pm »
- Run F9 (it'll compile) maybe offering to debug ...
 - But project1.lpr(13,10) Error: Cannot find Unit1 used by project1 of the Project Inspector.
What does this mean? "It'll compile" - but there is a compilation error message.

When I follow your listing of steps I do not have this error... But maybe there is still somethin which I am missing. I don't know, but is it important that there are two "project1" in your steps? I could imagine that the IDE gets confused in this situation

BrunoK

  • Hero Member
  • *****
  • Posts: 763
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #17 on: December 04, 2025, 05:10:44 pm »
- When I saved the form as unit2, it (IDE) didn't correct the project1 replacing name of unit1 by unit2.
In the project1.lps and project1.lpi it refers to <Filename Value="unit2.pas"/> but it is not changed in the uses clause of the project1.lpr, it remains as unit1.

That's all.

wp

  • Hero Member
  • *****
  • Posts: 13336
Re: Lazarus IDE problem?
« Reply #18 on: December 04, 2025, 05:35:02 pm »
It doesn't do this for me: After saving the initial unit1 as unit2 I opened the project1.lpr and .lps files with Notepad++ outside the IDE and they clearly contain "unit2". But I have seen your case in many test projects, therefore I still believe that I am missing a tiny detail in your steps.

Ah, but here is a way I can reproduce your issue - by introducing an error which obviously is not detected before saving:

- Open the IDE
- In the uses clause remove the trailing semicolon after "unit unit1;"
- File > New > Application
- "Save changes to project1" - yes: Keep project1 as project name, save unit1 under a different name as unit2.
- Keep the IDE open, and open project1.lpr in an external editor (Notepad++) - now unit1 is listed!
- Open the previously saved project1 from the history list. Compile & run --> "cannot find unit1 used by project1"

BrunoK

  • Hero Member
  • *****
  • Posts: 763
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #19 on: December 04, 2025, 05:50:59 pm »
Well, I would expect that since the saving of units is done under the IDE control, the IDE would adjust the reference in the project's .lpr file to reflect the selected name.

BrunoK

  • Hero Member
  • *****
  • Posts: 763
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #20 on: December 04, 2025, 05:52:48 pm »
But frankly, knowing that the IDE behaves like that is not a problem ... ;-)

 

TinyPortal © 2005-2018