Recent

Author Topic: Circular unit reference between Types and Windows  (Read 1327 times)

GMB

  • New Member
  • *
  • Posts: 13
Circular unit reference between Types and Windows
« on: February 11, 2025, 04:59:42 pm »
I just installed Lazarus 3.8 which included FPC 3.2.2 on Windows-7 and created a simple visual program. I got the above error.
Weirdly, if I comment out the  "uses Windows" in types.pp (just to see why the hell Types is using Windows) it still gives the same error!

So what is this about?

NB: I did have an ancient FPC and Lazarus installed, but to ensure this error is not confusion I have renamed the old FPC and LAZARUS folders so anything that might have known them will fail.


GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #1 on: February 11, 2025, 05:19:00 pm »
FURTHER:
If I make a trivial raw command line program (a classic hello world, all 4 lines) then...
LAZARUS gives the same error
FPC compiles and runs it with no problem.
It is as if Lazarus is loading Types or Windows on its own account and thereby messing things up ??

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12105
  • FPC developer.
Re: Circular unit reference between Types and Windows
« Reply #2 on: February 11, 2025, 10:49:51 pm »
The correct question would be why Windows imports types.  Types imports windows, but windows doesn't import types.

So the error doesn't make sense, unless you have some modified or previous FPC versions that the current FPC finds.

Past (pre 3.2, maybe 3.0.4?) Types didn't import Windows, but because Types abstracts some types originally in Windows (Tpoint,Trect etc), that caused type compatibility when the type was declared in an unit with Windows first, and used in an unit with types first.

So that got rectified, so on Windows, these are now declared in Windows and then aliased in Types.


GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #3 on: February 12, 2025, 06:36:29 pm »
It does indeed not make sense.

I have now uninstalled it, and deleted the files the UNINSTALL failed to delete.
Then reinstalled but this time without it being aware of previous installs and I told it to scrub any previous configs.

The result is only slightly better:
The raw FPC project now compiles OK - and works.
A visual project that I previously made gives the same old error.
STOP PRESS: I just noticed that THIS TIME it has gone and found and types.pp on an old archive disc that it should not have had any way of finding!!
Previously the types.pp was correctly listed as part of the install folder.

GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #4 on: February 12, 2025, 06:48:14 pm »
I see the problem. For unknown reasons the installer has set it up using an ancient archive disc for the FPC stuff even though I was done as a fresh install.

I am not even sure what the correct locations are for some of it. This looks like a bug in the installer to me.

wp

  • Hero Member
  • *****
  • Posts: 12676
Re: Circular unit reference between Types and Windows
« Reply #5 on: February 12, 2025, 06:51:49 pm »
FURTHER:
If I make a trivial raw command line program (a classic hello world, all 4 lines) then...
LAZARUS gives the same error
FPC compiles and runs it with no problem.
It is as if Lazarus is loading Types or Windows on its own account and thereby messing things up ??
Please post such a simple program source files, I do not understand what you are doing. Never had to use neither Types nor Windows in a commandline program.

GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #6 on: February 12, 2025, 06:57:02 pm »
The installer is getting annoying. I uninstalled and removed the only clue I could find to an old older containg FPC - which for some reason was the PATH.

So again did a cold install and again the OPTIONS are set up wrong.
BUG in the installer - it should load the initial setup using the FPC it just installed and not some old one it has found, somehow.

Seems I must exterminate my old (working) system to get this to work.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10897
  • Debugger - SynEdit - and more
    • wiki
Re: Circular unit reference between Types and Windows
« Reply #7 on: February 12, 2025, 07:47:06 pm »
I see the problem. For unknown reasons the installer has set it up using an ancient archive disc for the FPC stuff even though I was done as a fresh install.

I am not even sure what the correct locations are for some of it. This looks like a bug in the installer to me.

If you are installing on Windows then the installer asks you for a location where to install. It will propose the default of
Code: Text  [Select][+][-]
  1. c:\lazarus\
Everything will be installed within the folder that you selected at that time.

FPC will be installed in
Code: Text  [Select][+][-]
  1. C:\lazarus\fpc\3.2.2
(of course the C:\lazarus part will follow your selection)

Please be aware, that once you installed, you must not (are not permitted to) move or rename that folder. If any part of the fpc folder (including the part c:\lazarus) changes, then it wont work.



About clean install => uninstall does not remove your config. Your old config remains in %appdata% (that is in your user folder as given by windows)

However, when installing there is an option to clean that.

If you do a "secondary install" you can choose an empty folder for config.


Config contains info where FPC is installed (so people who install it separately can change that)


Please specify

1) What path did you specify in the installer as path
2) Does the sub path for fpc exist
3) C:\lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg => open and check what paths it contains.
4) In the IDE, menu: Tools > Options => what directory / filename for fpc is set?


GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #8 on: February 12, 2025, 08:04:31 pm »
4th install and this time the options are correct, but now it is worse!
My trivial project now pulls up the types.pp from the correct place and gives the circular error again:
program laztest3;
{$mode objfpc}{$H+}
begin
  writeln('GMB testing');
  readln;
end.
FYI I install in G:\LAZARUS (initially empty folder).
NOTHING IS CHANGED AFTER INSTALL

UPDATE: I did BUILD rather than RUN and now it compiles OK and now runs OK.
Back to a visual project. IT FAILS AGAIN.
G:\LAZARUS\fpc\3.2.2\source\rtl\objpas\types.pp gets loaded with the error message.
The fpc.cfg file has all the correct paths in it (now).
The file I installed is lazarus-3.8-fpc-3.2.2-win32.exe
« Last Edit: February 12, 2025, 08:20:05 pm by GMB »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10897
  • Debugger - SynEdit - and more
    • wiki
Re: Circular unit reference between Types and Windows
« Reply #9 on: February 12, 2025, 08:21:07 pm »
if "build" helped then in any other project that has the issue, open the folder in Windows, and search and remove all *.ppu and *.o files => just in case any of them are "broken".

If your project uses 3rd party packages (not in the Lazarus folder), then do the same in each of those packages..

Anything in the Lazarus folder should be ok => since the folder was empty before it can not contain old files.

If you have OPM packages, then be aware they are in your "config path". => and they will have survived from whatever old stuff you had. The should get removed only if you select "clean config" during install (install, not uninstall).
Though, that option is to clear config file, I am not 100% sure it will really go after old opm files.


You can find your config by looking in the IDE under menu: View > Ide Internals > About IDE
And then search for "Primary config path"
- backup and remove all that is in that folder.

GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #10 on: February 13, 2025, 01:30:38 pm »
It did not help.

I think I have another clue, what it failed to say until I added "uses Types" to my working trivial program is that is has somehow found the Borland version of Windows.pas !!
« Last Edit: February 13, 2025, 01:34:09 pm by GMB »

GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #11 on: February 13, 2025, 01:55:43 pm »
It wasn't a path problem but that issue is fixed.
I didn't see the problem because on clicking the unit "Windows" it showed me the correct library unit rather than the file that it had actually read!! Not helpful.

So now the trivial visual program gives this error:

Cannot find forms used by Unit1, incompatible ppu=G:\LAZARUS\lcl\units\i386-win32\forms.ppu package LCLBase.

GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #12 on: February 13, 2025, 03:12:30 pm »
I loaded the LCL source files into my project folder so that all the visual units were recompiled - and it now works just fine!

But the PPU files are exactly the same. So what is the actual issue?
I note that the .O files seem distinctly different
 
« Last Edit: February 13, 2025, 03:19:39 pm by GMB »

GMB

  • New Member
  • *
  • Posts: 13
Re: Circular unit reference between Types and Windows
« Reply #13 on: February 13, 2025, 03:51:28 pm »
FYI I found that I can delete the lcl\units\i386-win32 folder in the installed files and it then works properly after a delay while it compiles the library.

So it seems that the current install file definitely needs to be fixed.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10897
  • Debugger - SynEdit - and more
    • wiki
Re: Circular unit reference between Types and Windows
« Reply #14 on: February 13, 2025, 03:56:45 pm »
I loaded the LCL source files into my project folder so that all the visual units were recompiled - and it now works just fine!

Ouch, don't ... Then there are several versions of the ppu for each of those files => that will eventually cause issues.


You already found a way, to force recompile the units in place... Good.

Normally the IDE should detect that. But maybe because your fpc install had a different date, maybe? Don't know for sure.

If the IDE does not, you can normally open the package, and (in the dropdown at the right end of the toolbar) select "compile clean".

 

TinyPortal © 2005-2018