Forum > Designer
"Error: Unit Not Found" when adding event in Object Inspector
DarkBlueMonkey:
Hi There, (Newbie here),
I have a relatively simple Form, and I'm trying to add an event hook. The form only has one Control, an OpenGLControl. The moment I hit the ellipsis next to the event name (e.g. OnKeyPress) in the Form: Events tab in the Object Inspector, I instantly get
Codetools, errors: 1
unit1.pas(11,30) Error: unit not found: OpenGLContext
If I test it by deleting that unit from the uses clause, the error jumps to the error before that, uPSComponent. If I remove that, I get the error that it can't find the unit ExtCtrls... And so on and so forth until I get back to removing the uses for "Forms" at which point I get other errors because the main class is a Form, as you'd expect. Here's my "uses" list that's added automagically by Laz...
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
uPSComponent, OpenGLContext, gl;
Now, I can (sometimes) resolve the problem by reversing the uses of OpenGLContext and "gl" at the end there. But it usually doesn't help. If the code didn't compile I'd say there was a problem with my code... But it does compile, so I'm totally stumped.
Can anyone tell me why it's doing that... if only for my own sanity, it's been hindering me all evening till I just figured out the gl/OpenGLContext ordering.
Lazarus 2.2.0
Linux Mint 21.2
fpc 3.2.2+dfsg-9ubuntu1
everything else vanilla.
Many thanks in advance,
Nick
wp:
Has the package LazOpenGLControl been added to the requirements of the project? ("Project" > "Project Inspector" > see the tree nodes below "Required Packages"). Normally it should be added automatically when you drop the control on the form from the component palette. But who knows...
Since your project so far seems to be very simple you should create a new project and drop a TOpenGLControl on a new form. Try to compile. Does it work? Then repeat to assign an event handler - it should work.
What is uPSComponent? Are you sure that the package in which this unit is contained has no error and is properly installed?
Curt Carpenter:
Is there any possibility you can try your code on a windows box?
As I recall, I had a problem similar to this when using the rich text component from the online package manager. Worked OK with windows, but behaved badly on linux.
cdbc:
Hi
Maybe... just maybe, it could be something as mondane, as case-sensitivity in linux, regarding filenames / unitnames?!? %)
This sometimes creeps up on you, when you least expect it :o
Regards Benny
DarkBlueMonkey:
@wp - yes LazOpenGLControl was added. The program compiles and runs absolutely fine when I hit F9, and I've checked the l** files, and everything looks kosher.
@curt - sadly, not right now, I'm a linux-only person, but I do have a Windows VM tucked away somewhere, but it'll take me a while to get to it.
@cdbc - That's possible - Lazarus auto-generated all the directories, and I've used the "Rescan" option as someone suggested elsewhere. But the weird problem happens to me all the time.
In the end I went and hand-edited the hook into the lfm file and copied the function prototype from online. The program compiles and runs just fine, and the new event hook is called correctly.
However, if i try to use the Object Inspector, I simply can't add a new callback, I get the "Unit not found" error. Does anyone else use Laz on Linux (Specifically Debian/Ubuntu/Mint)?
Navigation
[0] Message Index
[#] Next page