Lazarus

Miscellaneous => Other => Topic started by: Prime on November 02, 2006, 01:29:05 am

Title: Converting from Delphi to Lazarus
Post by: Prime on November 02, 2006, 01:29:05 am
Hi,

I've been programming in Delphi for about 10 years now, and Pascal for nearly 20.....

I have just descovered freepascal & lazarus, and want to explore some more.
I have been able to convert some of my old TP stuff over to using FPC, but am having problems getting even simple Delphi (5 & 7) projects to compile under Lazarus.

So is there a beginner's step by step guide to converting a simple project from Delphi to Lazarus, I figure once I can do a simple one, porting something more comples will be much easier.

If it helps at the moment I'm working in Windows, but the attarction of FPC/Lazarus is the ability to also compile under Linux and MacOS (amongst others).

Cheers.

Phill.
Title: RE: Converting from Delphi to Lazarus
Post by: felipemdc on November 02, 2006, 03:09:23 am
Welcome =)

There is specific documentation about migration from Delphi here:

http://wiki.lazarus.freepascal.org/Lazarus_For_Delphi_Users

and here:

http://wiki.lazarus.freepascal.org/Code_Conversion_Guide

You will see that the wiki is the main documentation repository for Lazarus. (Free Pascal is a separate project, so it´s docs are separate).
Title: Re: RE: Converting from Delphi to Lazarus
Post by: Prime on November 02, 2006, 11:30:29 pm
Quote from: "sekel"
Welcome =)

There is specific documentation about migration from Delphi here:


Cheers for those, they where exactly the sort of thing I was looking for.

Now I have a trivial app ported, I will try a non-trivial one......

Phill.
Title: Re: Converting from Delphi to Lazarus
Post by: zouriteman on August 18, 2020, 05:41:45 pm
I thinks what your specific documentation are too much general, and a wiki list with several  exemples is better.
I begin to convert a little project  from DELPHI5 (or DELPHI7) to LAZARUS , but I uses several FREE components  (download from TORRY.NET) , as  DsfancyButton , GradBtnH , LsFileView28 , and PROLIB18
MANY PROBLEMS :
1)  add {$ASMMODE INTEL}  because small ASM code with  "MOV EAX,ax"
2)  type TTextStyle   unknown 
3)  uses WinTypes, WinProcs    ==> convert to  USES WINDOWS
4)  DBTables does not exist in LAZARUS  :  replace with  what ??????
5)  several TCreateParams   in ERROR !! ===> add   USES LCLType
6)  several SWITCHS unknown :  $SAFEDIVIDE  ,  $L  , $Y  , $OBJEXPORTALL
7)  problem with Ressource File ProConst.R16  in PROLIB18
8)  function SysUtils.GetDiskFreeSpaceEX  does not exists ==> you have to built a function with GetDriveIDFromLetter()  , DiskSize  , DiskFree

9)  property CTL3D  and ParentCTL3D  give me 3 errors : not Published , not Override , READ attempted    .... I do not understand why ???

... and so on ....

Can you begin a document with all samples post on the forum ?

Thanks !

Bad English, I am French , please !

Title: Re: Converting from Delphi to Lazarus
Post by: JuhaManninen on August 19, 2020, 01:32:43 am
Don't forget the automatic conversion under Tools -> Delphi Conversion.
Title: Re: Converting from Delphi to Lazarus
Post by: marcov on August 19, 2020, 11:47:32 pm
I thinks what your specific documentation are too much general, and a wiki list with several  exemples is better.
I begin to convert a little project  from DELPHI5 (or DELPHI7) to LAZARUS , but I uses several FREE components  (download from TORRY.NET) , as  DsfancyButton , GradBtnH , LsFileView28 , and PROLIB18
MANY PROBLEMS :
1)  add {$ASMMODE INTEL}  because small ASM code with  "MOV EAX,ax"

This is afaik not needed if you use mode delphi?

Quote
2)  type TTextStyle   unknown 

I can't find it in a recent Delphi either. So might be legacy that actually was eliminated from Delphi too.

Quote
3)  uses WinTypes, WinProcs    ==> convert to  USES WINDOWS

These are D1 units, and were already legacy by D2 times when unit "windows" emerged. We don't support all legacy options. Unfortunately, a lot of D6 and D7 era code are quite often conversions of earlier code without the legacy cleaned up.

It is note in the porting document  (http://www.stack.nl/~marcov/porting.pdf)though, but that is old.

Quote
4)  DBTables does not exist in LAZARUS  :  replace with  what ??????

Probably also such a legacy case, an older DBF/Paradox era unit from old pre SQL database support. Most of FPC's current DB was directly created with SQL usage(more  D4-D6+) in mind.

Quote
5)  several TCreateParams   in ERROR !! ===> add   USES LCLType

If it is in unit windows in Delphi, it can't be in unit Windows for the LCL, since unit Windows doesn't exist on Linux. Note that modern delphi also has some of such (system.* and vcl.*) units for the same reason.

Quote
6)  several SWITCHS unknown :  $SAFEDIVIDE  ,  $L  , $Y  , $OBJEXPORTALL

$safedivide is legacy again, for the early Pentium-I divide bug. Current OSes typically don't run on P-I hardware.

Afaik $L should be supported, but the object format might vary.  $Y is also supported (https://www.freepascal.org/docs-html/prog/progch1.html)

$objexportall is not for Delphi, but for Delphi-C++ builder interoperability. We don't have a such a closely knit C++ compiler, so this is redundant.

Quote
7)  problem with Ressource File ProConst.R16  in PROLIB18

The R16 probably means it is an old Win16 resource, the legacy bit again. D2 and newer support 32-bit resources.

Quote
8)  function SysUtils.GetDiskFreeSpaceEX  does not exists ==> you have to built a function with GetDriveIDFromLetter()  , DiskSize  , DiskFree

getdiskfreespaceex is not in sysutils but a Windows API routine. It is there also under Free Pascal.

Quote
9)  property CTL3D  and ParentCTL3D  give me 3 errors : not Published , not Override , READ attempted    .... I do not understand why ???

CTL3d is obsoleted by microsoft, iirc it was some Win98 (Office 97?) 3D button effect (https://docs.microsoft.com/en-us/cpp/mfc/tn051-using-ctl3d-now-and-in-the-future?view=vs-2019 )


Quote
... and so on ....

Can you begin a document with all samples post on the forum ?

That's what the wiki is for. Create an article there.
Title: Re: Converting from Delphi to Lazarus
Post by: wp on August 20, 2020, 12:23:22 am
I uses several FREE components  (download from TORRY.NET) , as  DsfancyButton , GradBtnH , LsFileView28 , and PROLIB18
Converting a third-party component is a project of its own. Look in Online-Package-Manager whether similar components are available for Lazarus. But be prepared that they may have different properties and may behave differently. My personal opinion: A "fancy" button is not worth the effort, at least for an initial version. Since you will not be able to load your project if you don't have these third-party components for Lazarus, I'd absolutely try to replace them by standard Delphi components which have a counterpart in Lazarus. If you still have a Delphi version available you always have a working project this way. Once you made the conversion to Lazarus you cannot go back in most cases.
Title: Re: Converting from Delphi to Lazarus
Post by: PascalDragon on August 20, 2020, 09:49:28 am
I thinks what your specific documentation are too much general, and a wiki list with several  exemples is better.
I begin to convert a little project  from DELPHI5 (or DELPHI7) to LAZARUS , but I uses several FREE components  (download from TORRY.NET) , as  DsfancyButton , GradBtnH , LsFileView28 , and PROLIB18
MANY PROBLEMS :
1)  add {$ASMMODE INTEL}  because small ASM code with  "MOV EAX,ax"

This is afaik not needed if you use mode delphi?

Only on i386 and i8086 it will indeed set the assembler mode to Intel if the mode is set to Delphi or TP.

Quote
... and so on ....

Can you begin a document with all samples post on the forum ?

That's what the wiki is for. Create an article there.

Well, there already is the Code Conversion Guide (https://wiki.freepascal.org/Code_Conversion_Guide) that can always be improved (and judging by the history this has already been improved since felipemdc posted that link back in '06).
Title: Re: Converting from Delphi to Lazarus
Post by: marcov on August 20, 2020, 01:13:47 pm
Well, there already is the Code Conversion Guide (https://wiki.freepascal.org/Code_Conversion_Guide) that can always be improved (and judging by the history this has already been improved since felipemdc posted that link back in '06).

Create or amend an article in the circular electronic doc-graveyard then.  :)

Note that such articles are only hints. There are too many variables to make it a blind conversion.


And then there is the fact that often the wiki is outdated. E.g. it is afaik perfectly possible nowadays to retain the .dfm extension for your forms.
TinyPortal © 2005-2018