[Lazarus] Having trouble using Indy inside command line program

Bo Berglund bo.berglund at gmail.com
Sat Dec 16 22:16:11 CET 2017


Probably something very basic that I have not remembered given the
frequency with which I create new projects....

I am using Lazarus 1.6 with fpc 3.0.0 on Windows 7.
Inside Lazarus I have installed the Indy components and I have
successfully built some GUI programs where I have used Indy components
and it worked just fine.
I was also able to build the same program on a Raspberry Pi box using
Lazarus/FPC on that box. Worked fine there too.

Now I am creating a command line program for use as a Subversion
commit hook handler and suddenly Indy seems to cause problems...
I am using Lazarus so I can build the same program also on Raspbian.

I have not yet even created a single Indy object, all I have done is
the following:

1) I added indylaz as a project "required package"
2) I added a number of Indy units to my uses clause in the mailer unit
since I know that I will need them down the road.

And now when I try to compile my code (which does not contain any Indy
objects yet) I get this error:

Compile package indylaz 10.6.2: Exit code 1, Errors: 2
IdGlobal.pas(1405,14) Error: Identifier not found "Windows"
IdGlobal.pas(1405,30) Error: Illegal expression

The error points into this section of code inside the IdGlobals.pas
unit (Line 1405 is Infinite = Windows.INFINITE; ):

  {$IFDEF WINDOWS}
  GOSType = otWindows;
  GPathDelim = '\'; {do not localize}
  Infinite = Windows.INFINITE; { redeclare here for use elsewhere
without using Windows.pas }  // cls modified 1/23/2002
  {$ENDIF}


Questions:
----------
A) Why is it trying to compile Indy?
Nothing from Indy is yet used and the package was already compiled
when it was added to the Lazarus palette....

B) Why does it not find the Windows unit?
It was clearly working when I installed the package into Lazarus
and when I was building GUI style programs using Indy both on Windows
and Linux.

C) Must I add the Windows unit to uses in all of my own units where
indylaz or one of the Indy units are referenced?

This is the start of my main project file:

program SvnMailer;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes,
  IniFiles,
  SysUtils,
  Process, // Process is the unit that holds TProcess
  indylaz,
  class_svnmailer
  ;

And this is the start of my unit where the Indy usage was prepared:

unit class_svnmailer;

{$mode objfpc}{$H+}

interface

uses
  Classes,
  SysUtils,
  IniFiles,
  {Indy units:}
  indylaz,
  IdSMTP,
  IdMessage,
  IdEMailAddress,
  IdIOHandler,
  IdIOHandlerSocket,
  IdIOHandlerStack,
  IdSSL,
  IdSSLOpenSSL,
  IdExplicitTLSClientServerBase;


-- 
Bo Berglund
Developer in Sweden



More information about the Lazarus mailing list