Recent

Author Topic: Windows service/daemon no longer compiles  (Read 556 times)

TyneBridges

  • Full Member
  • ***
  • Posts: 127
    • Personal blog
Windows service/daemon no longer compiles
« on: August 10, 2020, 11:49:30 am »
I've just uninstalled Lazarus 2.0.8 and installed Lazarus 2.0.10 in an attempt (with the help of PascalDragon) to add detection of user logons to a service which was basically written for me some years ago. I knew that I would have to recreate the service and realised this wouldn't be easy for a programmer with my limited ability. However, I've fallen at the first hurdle. The service (unchanged so far) that compiled and ran fine under the old Lazarus will no longer compile.

I've added LazDaemon to the new installation, rebuilt the IDE and attempted to build the service. I immediately see the following error:

Code: Pascal  [Select][+][-]
  1. Compile Project, Target: bc2.exe: Exit code 1, Errors: 1
  2. daemonmapperunit1.pas(15,17) Error: Forward declaration not solved "DaemonMapper1Create(TObject);"

I must be missing something obvious but don't understand why this would compile under the old Lazarus but now won't. Obviously there is code missing or not found, but what is that? I've checked the Wiki (https://wiki.freepascal.org/Daemons_and_Services), change logs and the Readme but can't see any mention of changes to how daemons work. I've attached my project.

Thanks for any help.
« Last Edit: August 10, 2020, 01:26:13 pm by TyneBridges »
John H, north east England
Lover of the old Delphi, still inexperienced with FPC/Lazarus and not an instinctive programmer
Tried .Net Core and was perpetually in knots, so am back here to try again with Windows clients

Thaddy

  • Hero Member
  • *****
  • Posts: 10516
Re: Windows service/daemon no longer compiles
« Reply #1 on: August 10, 2020, 11:52:31 am »
Rights?

TyneBridges

  • Full Member
  • ***
  • Posts: 127
    • Personal blog
Re: Windows service/daemon no longer compiles
« Reply #2 on: August 10, 2020, 12:06:51 pm »
Rights?

Sorry, I don't understand. If it was down to permissions, wouldn't the compiler say something like "File access denied"? I'm logged on as an Administrator and have not had that type of issue in Lazarus before.
« Last Edit: August 10, 2020, 12:41:04 pm by TyneBridges »
John H, north east England
Lover of the old Delphi, still inexperienced with FPC/Lazarus and not an instinctive programmer
Tried .Net Core and was perpetually in knots, so am back here to try again with Windows clients

paweld

  • Full Member
  • ***
  • Posts: 244
Re: Windows service/daemon no longer compiles
« Reply #3 on: August 10, 2020, 12:42:27 pm »
delete line 15 from DaemonMapperUnit ([procedure DaemonMapper1Create(Sender: TObject); )
or add definition of this procedure
Best regards
paweld

TyneBridges

  • Full Member
  • ***
  • Posts: 127
    • Personal blog
Re: Windows service/daemon no longer compiles
« Reply #4 on: August 10, 2020, 12:59:55 pm »
delete line 15 from DaemonMapperUnit ([procedure DaemonMapper1Create(Sender: TObject); )
or add definition of this procedure

Thanks! That fixed the compilation error. Obviously the way the FreePascal compiler treats undefined procedures has changed.

Unfortunately, removing the line allows the service to compile but not to run - it gives "OnCreate: Invalid value for property" on attempting to install it. As no property values were set in the old version, I don't know why this is happening or how to fix it. All this makes me realise how little I understand...
« Last Edit: August 10, 2020, 02:11:43 pm by TyneBridges »
John H, north east England
Lover of the old Delphi, still inexperienced with FPC/Lazarus and not an instinctive programmer
Tried .Net Core and was perpetually in knots, so am back here to try again with Windows clients

paweld

  • Full Member
  • ***
  • Posts: 244
Re: Windows service/daemon no longer compiles
« Reply #5 on: August 10, 2020, 01:37:00 pm »
this isn't empty procedure - it's not defined.
empty procdure is like this:
Code: Pascal  [Select][+][-]
  1. procedure empty;
  2. begin
  3. end;
Best regards
paweld

PascalDragon

  • Hero Member
  • *****
  • Posts: 2248
  • Compiler Developer
Re: Windows service/daemon no longer compiles
« Reply #6 on: August 10, 2020, 02:44:27 pm »
delete line 15 from DaemonMapperUnit ([procedure DaemonMapper1Create(Sender: TObject); )
or add definition of this procedure

Thanks! That fixed the compilation error. Obviously the way the FreePascal compiler treats undefined procedures has changed.

Unfortunately, removing the line allows the service to compile but not to run - it gives "OnCreate: Invalid value for property" on attempting to install it. As no property values were set in the old version, I don't know why this is happening or how to fix it. All this makes me realise how little I understand...

Check whether the OnCreate event is set in the object inspector when you switch to the form view of DaemonMapper1. If so, clear it.

Note: I really doubt that this originally compiled in 3.0.4, because the method definition of the event handler was simply missing.

TyneBridges

  • Full Member
  • ***
  • Posts: 127
    • Personal blog
Re: Windows service/daemon no longer compiles
« Reply #7 on: August 10, 2020, 02:53:13 pm »
delete line 15 from DaemonMapperUnit ([procedure DaemonMapper1Create(Sender: TObject); )
or add definition of this procedure

Thanks! That fixed the compilation error. Obviously the way the FreePascal compiler treats undefined procedures has changed.

Unfortunately, removing the line allows the service to compile but not to run - it gives "OnCreate: Invalid value for property" on attempting to install it. As no property values were set in the old version, I don't know why this is happening or how to fix it. All this makes me realise how little I understand...

Check whether the OnCreate event is set in the object inspector when you switch to the form view of DaemonMapper1. If so, clear it.

Note: I really doubt that this originally compiled in 3.0.4, because the method definition of the event handler was simply missing.

Thank you. There was an event there and clearing it did the trick - the old service will now compile and run. I hadn't realised the form view even existed in Lazarus for non-visual applications. Now for the next stage of creating a similar service including the detection of user logons.
John H, north east England
Lover of the old Delphi, still inexperienced with FPC/Lazarus and not an instinctive programmer
Tried .Net Core and was perpetually in knots, so am back here to try again with Windows clients

PascalDragon

  • Hero Member
  • *****
  • Posts: 2248
  • Compiler Developer
Re: Windows service/daemon no longer compiles
« Reply #8 on: August 11, 2020, 09:29:34 am »
Thank you. There was an event there and clearing it did the trick - the old service will now compile and run. I hadn't realised the form view even existed in Lazarus for non-visual applications. Now for the next stage of creating a similar service including the detection of user logons.

A form doesn't always exist for non-visual applications. It's just that daemon applications provide them for both the mapper and the daemon so that you could put direct TComponent descendants on them (e.g. database components). If you'd manually write a daemon application there wouldn't be a form.

 

TinyPortal © 2005-2018