Recent

Author Topic: Can not find unit?  (Read 4531 times)

MoellerCLaus

  • Full Member
  • ***
  • Posts: 114
    • Vig Foreningsprogram
Can not find unit?
« on: December 13, 2014, 11:16:20 am »
I have now spent some time finding the solution and it should be obvious but I am blinded.

I have made a component that uses the Grids (TStringGrid) unit (some objects used there).

When compiling it claims not to be able to find the grids.pas unit!

Where to put the path correctly?

I am using win32.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Can not find unit?
« Reply #1 on: December 13, 2014, 11:32:58 am »
Don't set any paths.
Make sure that in your component package you have a dependency on the LCL listed (use the Project Inspector). Add such a dependency if it is not listed.
Then ensure your component .pas file has
Code: [Select]
uses
 ..., grids, ...;

somewhere before your component class declaration.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4568
  • I like bugs.
Re: Can not find unit?
« Reply #2 on: December 13, 2014, 11:38:30 am »
It can be tricky sometimes to see the actual reason. Adding something to the Unit Search path is NOT a likely solution.
First check if Lazarus Codetools can find the unit (Ctrl-Click TStringGrid).
Mattias has written a nice wiki page with further instructions :
  http://wiki.lazarus.freepascal.org/Unit_not_found_-_How_to_find_units

Solution can be as simple as re-scanning the FPC sources.

[Edit] Now I realized you are doing a package, not an application, thus howardpc likely has the right answer. LCL or unit dependency is not added automatically then.
« Last Edit: December 13, 2014, 11:42:03 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MoellerCLaus

  • Full Member
  • ***
  • Posts: 114
    • Vig Foreningsprogram
Re: Can not find unit?
« Reply #3 on: December 13, 2014, 02:41:45 pm »
Thanks to you both. But the class is defined after the uses clause.

Error messages is

PPU Loading C:\lazarus\lcl\units\i386-win32\grids.ppu
PPU Source: grids.pas not found
PPU Source: lcl_dbgrid_images.lrs not found
clmcombobox.pas(55,7) Fatal: Can not find Grids used by clmCombobox, ppu=C:\lazarus\lcl\units\i386-win32\grids.ppu, package LCLBase

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Can not find unit?
« Reply #4 on: December 13, 2014, 02:57:01 pm »
Something seems to be amiss with your grids.ppu. Perhaps the compiler finds more than one?
Whatever the reason, it may be that the problem is with your Lazarus setup, not with your component package.
My suggestion would be to try uninstalling Lazarus, and then reinstall clean.
Drop a grid onto a new project and check that a simple do-nothing project that uses grids compiles and runs OK, before you try to compile your component package.

MoellerCLaus

  • Full Member
  • ***
  • Posts: 114
    • Vig Foreningsprogram
Re: Can not find unit?
« Reply #5 on: December 13, 2014, 03:18:35 pm »
Yeah you are right

PPU Loading C:\lazarus\lcl\units\i386-win32\grids.ppu
PPU Source: grids.pas not found
PPU Source: lcl_dbgrid_images.lrs not found
PPU Source: lcl_grid_images.lrs time 2011/05/09 08:07:30 *
win32wsfactory.pas(8,57) Fatal: Can not find Grids used by Win32WSFactory, ppu=..\..\units\i386-win32\grids.ppu, package LCLBase

It has apparanetly nothing to do with my own package. All of the examples projects with Grids works fine. Something with the grids.pas seems to have changed here on my PC.

I will have a deep dive.

MoellerCLaus

  • Full Member
  • ***
  • Posts: 114
    • Vig Foreningsprogram
Re: Can not find unit?
« Reply #6 on: December 16, 2014, 07:52:22 pm »
 ;D I am not sure I really found the reason.

My suspect no 1 is that if you don't reboot your PC after recompiling everything - you are going in circles!

It helped me out here.... Uhhh it is a bit scary

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Can not find unit?
« Reply #7 on: December 18, 2014, 04:37:41 am »
Um, normally you don't need to reboot your computer after compiling everything. Probably your antivirus/firewall is messing things up.

 

TinyPortal © 2005-2018