Recent

Author Topic: Problem installing Indy 10.2.0.3  (Read 33391 times)

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: Problem installing Indy 10.2.0.3
« Reply #15 on: February 10, 2016, 12:41:42 pm »
Did you see Sven's comment?
Yes, and please see my reply too.

Quote
I compiled and installed many lazarus package before and I never encountered this strange behaviour. By the way, if I add IdSync to indylaz.lpk everything works fine, so I find it hard to believe, this is a Lazarus IDE and Lazarus Packages issue.
I don't find it so hard to believe at all.  :) Your example of adding IdSync to indylaz.lpk just proves that. The IdSync unit is located in the unit paths specified in the indylaz.lpk package, so why doesn't Lazarus find it in the first place. If you ever review the actual compiler parameters that Lazarus IDE produces (run lazarus from a console window to see this easily), it makes many mistakes. It often injects compiler parameters I did not specify, adds conflicting parameters etc. This all has a knock-on effect and is one explanation why sometimes projects don't compile via Lazarus IDE, but does from the command line or from MSEide, Maximus IDE etc.

Quote
Even if it is a lazarus package issue, still need to be fixed, most of us works with lazarus not MSEide.
Yes indeed, but it doesn't help that the Mantis report is filed under the wrong project. Currently it is filed under the "mantis" project (where you report Mantis Bug Tracker bugs), when it should be filed under the "lazarus" project. So currently no Lazarus developer is going to see that report, or any notifications for it.
« Last Edit: February 10, 2016, 12:43:29 pm by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

GetMem

  • Hero Member
  • *****
  • Posts: 3508
Re: Problem installing Indy 10.2.0.3
« Reply #16 on: February 10, 2016, 02:30:36 pm »
@Graeme

I want to keep an open mind about this, so please attach the proof you mentioned on the bugtracker. If it is a Lazarus issue, I will do my best to fix it.

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: Problem installing Indy 10.2.0.3
« Reply #17 on: February 10, 2016, 04:07:58 pm »
@GetMem:  Take a look at the Mantis bug report. I've attached a project there. One of my comments explain what you need to modify to get it to work on your system.

http://bugs.freepascal.org/view.php?id=29564
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Problem installing Indy 10.2.0.3
« Reply #18 on: February 10, 2016, 04:10:25 pm »
@Graeme:

Just for demonstration purposes, add the IdStreamVCL unit at the top of the "uses" clause (to be sure it's compiled before the IdGlobal unit) in your test program.

Something like:
Code: Pascal  [Select]
  1. ...
  2. uses
  3.   {$ifdef unix}cthreads,{$endif}
  4.   Sysutils, Classes
  5.  
  6.   ,IdStreamVCL
  7.   // ftp client component
  8.   ,IdFTP
  9. ...
  10.  

This time, you'll see that this unit is compiled twice:
Quote
...
Free Pascal Compiler version 3.0.0 [2016/01/10] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Compiling C:\WORK\INTER\indy\Lib\System\IdStreamVCL.pas
Compiling C:\WORK\INTER\indy\Lib\System\IdGlobal.pas
Compiling C:\WORK\INTER\indy\Lib\System\IdException.pas
Compiling C:\WORK\INTER\indy\Lib\System\IdResourceStrings.pas
Writing Resource String Table file: IdResourceStrings.rsj
Compiling C:\WORK\INTER\indy\Lib\System\IdStream.pas
Compiling C:\WORK\INTER\indy\Lib\System\IdStreamVCL.pas
...

This is the origin of the problem for the Indy package installation within Lazarus.

I guess a workaround could be to force to compile IdGlobal before IdStreamVCL (by putting it in the first place of the package compilation).

AFAIR, it's OK in this later case.

Which is also the case for your "unmodified" test program, as IdGlobal is then compiled before IdStreamVCL (during the IdFTP unit compilation).
« Last Edit: February 10, 2016, 04:16:05 pm by ChrisF »

Graeme

  • Hero Member
  • *****
  • Posts: 1430
    • Graeme on the web
Re: Problem installing Indy 10.2.0.3
« Reply #19 on: February 10, 2016, 04:38:24 pm »
Just for demonstration purposes, add the IdStreamVCL unit at the top of the "uses" clause (to be sure it's compiled before the IdGlobal unit) in your test program.

And as you can see from the IdStream unit, you are not supposed to use IdStreamVCL directly, instead you should use IdStream and TIdStreamHelper if needed.

Indy is far from unique in this regards - circular dependencies or required order of a uses clause. I have seem many cases where different libraries have common class names etc and the uses clause order is important. In the case of Indy, they supplied the IdStream unit for you, which also defines the uses clause in the correct order.

Even the indylaz.lpk defines the order correctly... IdGlobal, IdStream and then IdStreamVCL. The latter unit shouldn't even be needed in the indylaz.lpk package.

Quote
I guess a workaround could be to force to compile IdGlobal before IdStreamVCL (by putting it in the first place of the package compilation).
As I mentioned, that is what the indylaz.lpk package already does.

Another test to show how Lazarus breaks a working project. As you now know my [mantis] attached example project compiles first time without error from the command line.
  • Now clean all compiled units of my test project, and clear the compiled units of the indylaz.lpk package.
  • Start Lazarus, open the indylaz.lpk and click compile. Only click the Compile button once. It should compile the package without error.
  • Now select "Project -> New from File...", select my test.pas unit, and select "simple application".
  • Now add the indylaz.lpk as a project dependency.
  • Now compile the test project.
Magically, Lazarus fails to compile the project with a mention of a missing unit, and an unexpected CRC changes in a PPU file. Why???  The build script worked just fine, so what does Lazarus IDE do to break the project?  Again, a Lazarus IDE issue. Not FPC, not Indy.
« Last Edit: February 10, 2016, 04:43:11 pm by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Problem installing Indy 10.2.0.3
« Reply #20 on: February 10, 2016, 06:40:50 pm »
The issue is not really concerning circular dependencies, but inlined procedures/functions into units with circular dependencies.

As a proof of concept, disabling the possibility to get inlined procedures/functions into Indy by adding the "-dDEBUG" option to the package compilation allows to install the Indy package without a second compilation.

Inlining within Indy is indeed undefined in all the IdCompilerDefines.inc files with:
Code: Pascal  [Select]
  1. ...
  2. {$IFDEF DEBUG}
  3.   {$UNDEF USE_INLINE}
  4. {$ENDIF}
  5. ...
  6.  

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Problem installing Indy 10.2.0.3
« Reply #21 on: February 10, 2016, 06:42:34 pm »
...
And as you can see from the IdStream unit, you are not supposed to use IdStreamVCL directly, instead you should use IdStream and TIdStreamHelper if needed.
...

You're quite right. This was just a simple way to provoke the concerned "issue".