[Lazarus] Problem Finding Units

David Riley dmfnr1 at gmail.com
Sat Jul 9 15:27:45 CEST 2011


On Fri, 2011-07-08 at 12:41 +0100, Martin wrote:
> On 08/07/2011 12:16, David Riley wrote:
> > After I removed the references to TSynHighlighterPas and replacing them
> > with my own, I started to run in to this odd problem.  All of a sudden
> > when attempting to build, FPC reported that it was unable to find the
> > SynEdit unit.  SynEdit is included as a dependency in the project
> > inspector, and here's the bizarre part.  After reporting that it cannot
> > find the unit, Lazarus actually opens the SynEdit.pp file in the editor.
> > What the hell does it mean it can't find it and then opens it in the
> > editor.  Hovering the mouse over the unit in the Uses block shows the
> > correct location for the unit (/usr/lib/... on Linux, c:\lazarus\... on
> > Windows).  So I copied the files from my source directory in to my
> > project directory, and then it was suddenly able to find the Unit, and
> > reported the next unit TSynEditTypes or whatever missing.  Even more
> > bizarre, if I delete all references to SynEdit in my project, and
> > attempt to create one from the component palette, it is now referencing
> > my project directory as the location of the unit.
> >
> 
> There is a difference between Lazarus and FPC finding it...
> 
> 1) Do not copy the files from the SynEdit package to your path. never ever.
> 2) Do not add any -Fu -Fi or other custom path to your project, that 
> points to synedit...
> 
> - In "project inspector", SynEdit is present as package under dependencies?
> - Make sure you have only one version of FPC. As soon as 2 versions 
> (even minor versions, even svn revisions) of FPC get's mixed, things go 
> unexpected....
> - Make sure, nowhere in your project, or in any path that you may have 
> added yourself to the project, is a synedit.ppu (or any ppu for 
> synedit*, except your highlighter)
> - Compile with -va (and look add all+hidden msgs) to see where fpc looks 
> for the file, and why they may be rejected. (a lot of output in msgs)
> 
> I assume you create the new highlighter in code? As it is not 
> registered, you can not ue it on the form designer. (nor put it by hand 
> into the lfm)
> 
Yes, the highlighter is currently in code, I'm not quite ready to mess
with registering it yet as it is still under heavy development and I'm
more comfortable just having it as a separate unit in my project.

I've done some experimenting with just the highlighter unit and an empty
project, and when I removed the {$I synedit.inc} line from the
highlighter (I'm currently using none of the defines in the file anyway)
everything compiled fine.  So looking through the verbose output as you
told me to, I found that the synedit.inc file is in the source directory
or the synedit folder which is not in the search path.  I also found
that in that project that the compiler searched for synedit.pp instead
of the compiled .ppu files in the units directory.  So now at least I
have a good workaround so I can continue development and testing on the
highlighter.

Excuse my lack of knowledge on the way units work in Pascal, I'm still
learning "The Pascal Way" which is very nice, but a bit different that
what I'm used to.  I'd imagine in this case it's probably best to create
a separate project for the highlighter itself and compile it in to it's
own unit and learn the process of registering a component in the ide?
That way once I start finishing up the highlighter and add in the
conditionals in the proper spots (for Delphi compatibility and such,
like is featured in the other highlighters) I won't have to worry about
the synedit.inc file messing up the search paths for the larger
project.  

Thank you very much for your help Martin, it is much appreciated, I
think I have this figured out now, and I actually learned quite a bit in
the process.  Thanks again for your time.  





More information about the Lazarus mailing list