Page 1 of 2
Install problem on Lazarus
Posted: 09.06.2008, 09:36
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?
Posted: 09.06.2008, 11:39
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
Posted: 09.06.2008, 12:38
by Dr Mac
You're right, I'm using 64 FPC. So I'm sad a little bit, but hope the best.
Posted: 09.06.2008, 14:24
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.
Posted: 09.06.2008, 17:01
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.
Posted: 09.06.2008, 20:27
by mdaems
Before you reinvent the wheel again :
http://zeos.firmos.at/viewtopic.php?t=1848
This can maybe help as well?
Mark
Posted: 09.06.2008, 21:04
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
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
Posted: 09.06.2008, 21:58
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
I'm a little bit tired now, so I'm going to slepp. Tomorrow ...
Posted: 10.06.2008, 08:38
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
Posted: 10.06.2008, 18:25
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?
Posted: 10.06.2008, 23:56
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
Posted: 11.06.2008, 16:56
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.
Posted: 13.06.2008, 12:49
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.
Posted: 13.06.2008, 13:04
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.
Hum
Good to know that it's working =)
Can you make a benchmark concerning Lazarus 32 and 64 ? It would be interesting!
Posted: 13.06.2008, 14:08
by hgourvest
Dr Mac,
You should used PtrInt datatype instead of Int64 for transtyping.
{$IFNDEF FPC}
PtrInt = longint;
{$ENDIF}
herni