Recent

Author Topic: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5  (Read 18127 times)

ozoltan

  • New Member
  • *
  • Posts: 37
Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« on: January 24, 2015, 06:32:35 pm »
Hi...

I am trying to install Indy 10.6.1.5238 version under Lazarus 1.2.6 using Debian 7.5, but its not working...
For install It works as described here: http://wiki.freepascal.org/Indy_with_Lazarus

My problem is that after installing everything seems ok, but I cannot use Indy. A very simple program:

----------------------------------------------------------------------------------------------------------------------------------------------------

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, IdIPWatch;

type

  { TForm1 }

  TForm1 = class(TForm)
    IdIPWatch1: TIdIPWatch;
    procedure FormActivate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormActivate(Sender: TObject);
begin
  ShowMessage(Form1.IdIPWatch1.LocalIP);
end;

end.


----------------------------------------------------------------------------------------------------------------------------------------------------

It's not working. It compiles, the program runs, but it displays nothing. Also when I am writing the program,
if I put a '.' after an object, then Lazarus should display the properties, events, etc of that object... For IdIpWatch1
object it displays nothing, but it compiles...

I have tried to install previous versions of Indy: 10.6.1.5203 and 10.2.0.3... But none of them are working. All
makes the same error...

I dont understand... Can anybody help ?

Thank You in advance!

Zoltán


ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #1 on: January 25, 2015, 01:43:27 am »
If you can compile and run your program with an Indy component inside, most probably your installation is OK.

What do you mean exactly by: "It's not working" ? Do you mean that the ShowMessage box is displayed with no data inside ? Or not displayed at all ?

Anyway, it seems to me it's probably relative to the Linux implementation of Indy, as your test program is working OK here (but with a Windows OS).

** Edit ** AFAIK, displaying the properties/methods of an object is sometimes a bit "capricious" inside the Lazarus IDE. So, it's probably not a clue to your problem.
« Last Edit: January 25, 2015, 01:48:12 am by ChrisF »

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #2 on: January 25, 2015, 07:06:05 am »
Exactly as You say... Showmessage displays and empty string. Under Windows its working perfectly...
My problem is that I have tried 2 previous versions of Indy, and I got the same result. No properties display
when writing a program and not working - empty string.

This is what I really dont understand...

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #3 on: January 25, 2015, 02:52:12 pm »
Have you tried some other functionalities of Indy (a few very common ones) ? Are they working properly ?

Apparently, it seems that there was a problem with IDIpWatch.currentIP on Linux in the past: see http://forum.lazarus.freepascal.org/index.php?topic=8985.0

It may eventually be still not solved.

I guess you may find a more appropriate answer to your specific problem in the Indy forum : http://forums2.atozed.com/ . Especially from Remy Lebeau, the current coder maintaining Indy.

BTW, someone has reported me a problem to register to this forum recently: I don't know if it's now solved.

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #4 on: January 25, 2015, 05:27:11 pm »
No. I havent tried any other functionalities of Indy. From Indy I used only this IDIpWatch to get the current IP of the computer and another 2-3 objects to send emails...

As far as I know on Indy 9.x the IDIpWatch property was called CurrentIP, it has been changed to LocalIp since Indy 10.x versions.
The funny thing is that even if I write LocalIP or CurrentIP, Lazarus accepts both of them, no error message, but still not working...

I have registered to the Indy forum, I will ask Remy Lebeau.
Registering to Indy forum worked for me for the 2nd chance :) It has a question and the end of the registration form which wasnt clear enough for me for the 1st sight :) But it works :)

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #5 on: January 26, 2015, 10:20:50 am »
Basically my problem is that Indy 10.2.0.3 was working on a prevous Lazarus, if I remember well then it was Lazarus 0.9.30
and on Debian 5.0.2

Now even that Indy is not working on Lazarus 1.2.6 and Debian 7.5



ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #6 on: January 26, 2015, 03:13:29 pm »
Interesting...

Though I'm not sure it's relative to Lazarus, but perhaps to FPC instead.

After a quick glance at the Indy source code, IdIPWatch uses threads for its functionalities (especially for the current IP address). So, I think it could be relative to the interactions between Indy and FPC concerning the thread implementation (but this is only a supposition of mine).

Hereafter, a sample FPC program to make a test (not tested on a Linux OS).

If you wish to make a test:
- create a "Simple Program" project (i.e. without the LCL),
- add Indy into the project dependencies,
- use the following code

Code: [Select]
program project1;

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
{$ENDIF}{$ENDIF}
  IdIPWatch;

var IsOK: Boolean;
var MyIdIPWatch: TIdIPWatch;

begin
  IsOK := True;
  try
    MyIdIPWatch := TIdIPWatch.Create;
  except
    WriteLn('** Error when creating TIdIPWatch **');
    IsOK := False;
  end;
  if IsOK then
    begin
      WriteLn('Current local IP = '+MyIdIPWatch.LocalIP);
      MyIdIPWatch.Free;
    end;
end.

« Last Edit: January 26, 2015, 03:35:43 pm by ChrisF »

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #7 on: January 26, 2015, 09:28:02 pm »
Chris ... I have tried the code You have suggested me... The result is the same... It compiles and runs without problem, but the result is an empty string... :(

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #8 on: January 27, 2015, 01:14:55 am »
Which means, as you've written it was working for Indy 10.2.0.3 and Lazarus 0.9.30, that it's probably the FPC version which is determinant in your case (don't know which one was used for this old version of Lazarus).

And if it was OK with Indy 10.2.0.3 in the past, and no more now, it's -once again probably- because of a modification inside FPC.

It seems that there is something wrong between Indy and FPC: relative to threads ? (the by-default use of the CThreads unit has been added "recently", AFAIK). And I guess there have been some other changes too.
« Last Edit: January 27, 2015, 01:50:41 am by ChrisF »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #9 on: January 27, 2015, 03:30:48 am »
Don't you need to add to the custom options -dUseCThreads?

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #10 on: January 27, 2015, 11:54:02 am »
ChrisF...

Sorry.. I was mistaken... The previous version of Lazarus was 0.9.26.2 that came along with fpc 2.2.2.3
That was when I have used Indy 10.2.0.3 and it worked. It was under Debian 5.0.2

I am afraid that You are right concerning the modifications about Lazarus and fpc, because as I have described
previously, none of the previous Indy versions - indy 10.2.0.3 and 10.6.1.5203 - is working now. All three versions
makes the same error in Lazarus... So probably the problem must be somewhere much deeper...


Engkin...

The compiler did not complained about -dUseCThreads option, it compiled the little program that ChrisF asked me
to test. Also I could run the test program, only the result is an empty string... :(

balazsszekely

  • Guest
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #11 on: January 27, 2015, 02:04:19 pm »
Hi Zoltan,

You should try something like this:
Code: [Select]
uses IdHTTP;

function GetMyIP(const IPAPI_URL: String; var IP: String): Boolean;
var
  SS: TStringStream;
  IdHTTP: TIdHTTP;
begin
  Result := False;
  IdHTTP := TIdHTTP.Create(nil);
  try
    IdHTTP.Request.UserAgent := 'Mozilla/5.0 (compatible; Test)';
    IdHTTP.HandleRedirects := True;
    SS := TStringStream.Create('');
    try
      IdHTTP.Get(IPAPI_URL, SS);
      if IdHTTP.ResponseCode = 200 then
      begin
        IP := SS.DataString;
        Result := True;
      end;
    finally
      SS.Free;
    end;
  finally
    IdHTTP.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  IP: String;
begin
  IP := '';
  if GetMyIP('http://www.trackip.net/ip', IP) then
    ShowMessage(IP);
end;               

If you cannot compile then:
Menu-->Project-->Project Inspector-->Add-->New requirement-->Package Name-->IndyLaz-->Create New Requirement
If you still have problems:
Project Inspector-->Options-->Complier Options-->Other unit files-->Locate the indy directory.

regards,
GetMem

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #12 on: January 27, 2015, 03:31:42 pm »
Hi GetMem...

Ur test program works!! That means that Indy is somehow working... BUT... Ur program displays my IP WAN address and
not LAN IP address... That I got calling IdIPWatch.LocalIP

My other problem is that when I want to use any Indy object, even IdHTTP... and while writing my program, when putting a
'.' after and object, Lazarus used to display to properties, events, methods of that object... So if I am starting to use an object
that I havent used it before, that way I can find out the capabilities of that object. But since for Indy objects Lazarus does not display its own little capability window... I have no idea what and how can I use :( But I am afraid that is some kind incompatibility between FPC / Lazarus and Indy... And mostly FPC / Lazarus, because Indy 10.2.0.3 was working for me previously...

regards
Zoltán

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #13 on: January 27, 2015, 06:07:48 pm »
Eventually, you can make another try with a modified version of my first FPC test program.

It's supposed to make the second and third tests without any thread call; though I'm not sure there are not some other ones, called deeper in the Indy source code. Plus IPV4/IPV6 for the third one.

Code: [Select]
program project1;
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
{$ENDIF}{$ENDIF}
  SysUtils, IdIPWatch, IdStack, IdGlobal;

var sResult: String;
var IsOK: Boolean;
var i: Integer;

var MyIdIPWatch: TIdIPWatch;
var LList: TIdStackLocalAddressList;

begin
  // First, the standard way
  IsOK := True;
  try
    MyIdIPWatch := TIdIPWatch.Create;
  except
    WriteLn('** Error when creating TIdIPWatch **');
    IsOK := False;
  end;
  if IsOK then
    sResult := ('Local IP (1)= ' + MyIdIPWatch.LocalIP)
  else
    Exit;
  // Then, using directly GStack.LocalAddress
  sResult := sResult + sLineBreak + ('Local IP (2)= ' + GStack.LocalAddress);
  // Finally, using directly GStack.GetLocalAddressList (whole list)
  IsOK := True;
  try
    LList := TIdStackLocalAddressList.Create;
    GStack.GetLocalAddressList(LList);
    for i :=0 to Pred(LList.Count) do
      begin
        sResult := sResult + sLineBreak + ('Local IP (3)= [' + IntToStr(Succ(i)) +'] ' + LList[i].IPAddress);
        if LList[I].IPVersion = Id_IPv4 then
          sResult := sResult + ' [IPV4]'
        else
          sResult := sResult + ' [IPV6]';
      end;
  except
    WriteLn('** Error when getting TIdStackLocalAddressList **');
    IsOK := False;
  end;
  // Free resources
  LList.Free;
  MyIdIPWatch.Free;
  if not IsOK then
    Exit;
  // Display the results
  Writeln(sResult);
end.



** Edit ** BTW, have you an IPV4 or an IPV6 local IP ? If you've got an IPV6 one, according to the comments into the Iny source code, it could explain why you only get a empty result.

in IdStack, function GetLocalAddress (and some others):

Code: [Select]
    // for backwards compatibility, return only IPv4 addresses
...
    GetLocalAddressList(LList);
    for I := 0 to LList.Count-1 do begin
      if LList[I].IPVersion = Id_IPv4 then begin
        Result := LList[I].IPAddress;
        Exit;
      end;
    end;
...



** Edit2 ** Have you tried CTRL+SPACE after the '.' character to try to force the display of the object/class properties ?
« Last Edit: January 27, 2015, 06:37:52 pm by ChrisF »

ozoltan

  • New Member
  • *
  • Posts: 37
Re: Indy 10.6.1.5238 for Lazarus 1.2.6 with Debian 7.5
« Reply #14 on: January 27, 2015, 06:42:32 pm »
Hi ChrisF...

I have tested this 2nd test program of Urs... the result is the following:

-------------------------------------------------------------------------------------------------------------------------------------
zoltan@debian:~/test2$ ./project2
Local IP(1)=
Local IP(2)=
zoltan@debian:~/test2$
-------------------------------------------------------------------------------------------------------------------------------------

Still empty string :( The command GStack.GetLocalAddressList(LList); probably returns with LList=Nil because nothing
else is displayed :(

According to ifconfig, my laptop has IPV4 type LAN address...  Well... It seems to me that I got some very real deep
problem... As I get back to my workplace i will try the email function, because that is what I need more...

regards
Zoltán

 

TinyPortal © 2005-2018