Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-12

Having trouble using Indy inside command line program

3 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

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

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote
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

This is caused by a seemingly erroneous ifdef construct in the file. I looked in the Indy repository and found that this has been modified in a later tagged version of he file without any modification to the Indy version, which is still the same.
I edited in that modification and then the above error disappeared.

Just a couple of more questions:

1) Why was Lazarus trying to re-compile indylaz when it is already installed and built? Makes no sense to me....
Of course after I edited the file it will need a recompile, but why before?

2) Why does my project not find the Indy units when compiling? If I right-click these in Lazarus and select "Find declaration of" it immediately opens the specified file. But while compiling I get unit not found on some.

I have "solved" this by adding the three source directories Core, Protocols and System to the
Project/Options/CompilerOptions/Paths/OtherUnitFiles Now the project compiles but it always gives this warning:

Warning: other unit files search path (aka unit path) of "SvnMailer" contains "D:\Engineering\Projects\CMPFPC\Indy10.6.2\System", which belongs to package "indylaz"

But if I include indylaz in the uses clauses it errors out like this instead:

SvnMailer.lpr(23,4) Fatal: Cannot find indylaz used by SvnMailer, incompatible
ppu=D:\Engineering\Projects\CMPFPC\Indy10.6.2\lib\i386-win32\indylaz.ppu, package indylaz

Finally, if I remove indylaz as a Required Package for the project, then it compiles without errors but with a whole lot of warnings and hints. The warnings deal with string conversions within Indy. Here is one such, there are a lot more.:

IdSSLOpenSSL.pas(2140,18) Warning: Implicit string type conversion
with potential data loss from "UnicodeString" to "AnsiString"

What is going on here, really..?

3) And what should I do when creating a "Program" application in Lazarus to make it possible to use the units from indylaz without fussing with the paths to the Indy sources?
The program should be possible to build also on Linux.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Bo Berglund wrote
3) And what should I do when creating a "Program" application in Lazarus to make it possible to use the units from indylaz without fussing with the paths to the Indy sources? The program should be possible to build also on Linux.

I have gotten advice from Remy Lebeau (main keeper of the Indy project) to use what he calls "FPC's Online Package Manager" to install Indy in FPC. Or use Lazarus' OPM to do the same.

Well I found a wiki page I did not know about here: http://wiki.freepascal.org/Online_Package_Manager

I made a test on a RaspberryPi where I could easily install Lazarus 1.8.0 from sources and I already had FPC 3.0.4.

And it really was a simplification on the way I had earlier struggled to get Indy10 properly installed!

Bo Berglund Developer in Sweden

Reply by email