Install problem on Lazarus

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Install problem on Lazarus

Post by Dr Mac »

Hello!
I'm using a Debian AMD64 system. I was install FPC 2.2.0 (and source) and Lazarus 0.9.24 from packages. When I try to compile zcore package (Zeoslib 6.6.2-rc) it always comes up the following error:

Code: Select all

ZClasses.pas(258,13) Error: Illegal type conversion: "TZAbstractObject" to "LongInt"
and highlight the following piece of code:

Code: Select all

{**
  Gets a unique hash for this object.
  @return a unique hash for this object.
}
function TZAbstractObject.Hash: LongInt;
begin
  Result := LongInt(Self);
end;  
What should I do? Any idea?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I suppose you're using 64 bit FPC version? In that case I'm afraid you'll have to wait for a compatible Zeoslib version. This is not on the planning yet... User hgourvest thinks about contributing to the conversion but ... no promises yet.

Mark
Image
Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Post by Dr Mac »

You're right, I'm using 64 FPC. So I'm sad a little bit, but hope the best.
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Probably I'll be wrong, but...

This line of code, as the name says, "Gets a unique hash for this object" and it does it casting the current memory address to an LongInt value.

Well, LongInt is a 32 bits type (Check Here), and probably, in a 64 bits architecture, memory addresses are 64 bits long.

So, in summary, casting to Int64 type *may* solve the problem.
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Post by Dr Mac »

Thanks gto!
It was a good idea. Now here comes the another problem, now in the ZCollection.pas:

Code: Select all

ZCollections.pas(275,22) Error: Unknown identifier "EAX"
ZCollections.pas(275,23) Error: Assembler syntax error in operand
ZCollections.pas(275,27) Error: Unknown identifier "EBP"
ZCollections.pas(275,29) Error: Invalid constant expression
and the piece of code:

Code: Select all

{**
  Raises a collection error.
  @param Msg an error message.
  @param Data a integer value to describe an error.
}
class procedure TZCollection.Error(const Msg: string; Data: Integer);

  function ReturnAddr: Pointer;
  asm
          MOV     EAX,[EBP+4]
  end;
I think I must dive into the FPC documentation. :)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Before you reinvent the wheel again : http://zeos.firmos.at/viewtopic.php?t=1848
This can maybe help as well?

Mark
Image
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Dr Mac wrote:Thanks gto!
It was a good idea. Now here comes the another problem, now in the ZCollection.pas:

Code: Select all

ZCollections.pas(275,22) Error: Unknown identifier "EAX"
ZCollections.pas(275,23) Error: Assembler syntax error in operand
ZCollections.pas(275,27) Error: Unknown identifier "EBP"
ZCollections.pas(275,29) Error: Invalid constant expression
and the piece of code:

Code: Select all

{**
  Raises a collection error.
  @param Msg an error message.
  @param Data a integer value to describe an error.
}
class procedure TZCollection.Error(const Msg: string; Data: Integer);

  function ReturnAddr: Pointer;
  asm
          MOV     EAX,[EBP+4]
  end;
I think I must dive into the FPC documentation. :)
Uh, these are from 32/64 bits tricks again :D

EAX and EBP are registers from 32 bits processors which doesn't exists in 64-bit world. You should try with RAX and RBP.

I'm no expert but I think we may track all changes in this topic under some conditional compiling directives, like ENABLE_FPC_64BITS or something ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Post by Dr Mac »

So I'm a hobby programmer and I only want to use Zeoslib with MySQL. I never develop any serious program or component. But when I finished porting Zeoslib to 64 bit maybe I become an expert :D:D
I'm a little bit tired now, so I'm going to slepp. Tomorrow ...
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

gto,

Good idea.
Please check what compiler define is used for FPC 64.
Add it to zeos.inc. If set define something like $64_BIT. If not $32_BIT. (Imagine Borland/Codegear starts to support 64 bit as well, most changes should work equal, I hope.)
So : if changes work in both 32 and 64 bit no conditional source. If not use the $64_BIT and $32_BIT.

Also make sure you use the compatibility unit as much as possible. By (re)defining the right datatypes/functions in case of 64 versus 32 bit you can avoid conditional code all around the code.

Mark
Image
Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Post by Dr Mac »

So, I'm here again.
A made minor changes in 9 files. When I select zcomponent.lpk Lazarus compile all without problem and restart itself. But the Zeos components doesn't appears on the Component palette.

Any idea?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Please publish your changes here... (SVN diff?) I'm not capable of interpreting them, but others may.

Concerning the compoents in the palette : maybe some 64 bit specific difference in the component registration procedure?

Mark
Image
Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Post by Dr Mac »

So, here are my changes (diff).

ZAbstractRODataset.pas:

Code: Select all

1325c1325
<       DataEvent(deFieldChange, LongInt(Field));
---
>       DataEvent(deFieldChange, Int64(Field));
ZClasses.pas:

Code: Select all

258c258
<   Result := LongInt(Self);
---
>   Result := Int64(Self);
ZCollections.pas:

Code: Select all

273a274
> {$asmmode intel}
275c276
<           MOV     EAX,[EBP+4]
---
>           MOV     RAX,[RBP+4]
ZDatasetUtils.pas:

Code: Select all

1285c1285
<     Result[I] := Integer(Fields[I]);
---
>     Result[I] := Int64(Fields[I]);
1302c1302
<     if FieldsLookupTable[I] = Integer(Field) then
---
>     if FieldsLookupTable[I] = Int64(Field) then
ZPlainFirebird10.pas:

Code: Select all

400c400
<   libc;
---
>   baseunix, unix;
ZPlainFirebird15.pas:

Code: Select all

404c404
<   libc;
---
>   baseunix, unix;
ZPlainFirebird20.pas:

Code: Select all

405c405
<   libc;
---
>   baseunix, unix;
ZPlainLoader.pas:

Code: Select all

95c95
<   libc,
---
>   baseunix,unix,
ZStreamBlob.pas

Code: Select all

121c121
<         THackedDataset(FField.DataSet).DataEvent(deFieldChange, LongInt(FField));
---
>         THackedDataset(FField.DataSet).DataEvent(deFieldChange, Int64(FField));
That's all.
I try to inquire why components aren't appeared on the Component palette but no solution yet.

Important!
These changes are tested only on Debian Linux AMD64 system.
Dr Mac
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 09.06.2008, 09:20

Post by Dr Mac »

Another day, another interesting results.

I tried to install FPC and Lazarus on a 32 bit Debian system. Not from the Debian repository, but from original Lazarus download page (Sourceforge). After that I tried to install Zeos and it was successful. The components was on the Component palette.
Back to my 64 bit Debian. I removed all FPC and Lazarus packages, downloaded it from Sourceforge (not source, they also have DEB64 packages). Installed all packages and then tried to install Zeos. The result was the same like 32 bit Debian. Zeos components are on the palette now.

I'm very happy now. :D :D
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

Dr Mac wrote:Another day, another interesting results.

I tried to install FPC and Lazarus on a 32 bit Debian system. Not from the Debian repository, but from original Lazarus download page (Sourceforge). After that I tried to install Zeos and it was successful. The components was on the Component palette.
Back to my 64 bit Debian. I removed all FPC and Lazarus packages, downloaded it from Sourceforge (not source, they also have DEB64 packages). Installed all packages and then tried to install Zeos. The result was the same like 32 bit Debian. Zeos components are on the palette now.

I'm very happy now. :D :D
Hum :)

Good to know that it's working =)

Can you make a benchmark concerning Lazarus 32 and 64 ? It would be interesting!
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
hgourvest
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 21.05.2008, 08:34
Contact:

Post by hgourvest »

Dr Mac,

You should used PtrInt datatype instead of Int64 for transtyping.

{$IFNDEF FPC}
PtrInt = longint;
{$ENDIF}

herni
Post Reply