Recent

Author Topic: How to convert a Lazarus Project to Delphi 10  (Read 857 times)

thehidden

  • Jr. Member
  • **
  • Posts: 73
  • Freelancer
How to convert a Lazarus Project to Delphi 10
« on: March 04, 2021, 12:12:38 am »
Hi to all,

does anybody know about a tool to convert a Lazarus Project folder to Delphi? Best would be Delphi 10.33 or higher.

I need to convert a project to Delhi but I have found in the Wiki only information how to convert Delphi to Lazarus but not vice versa.

Thank you for help in advance.
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

wp

  • Hero Member
  • *****
  • Posts: 8300
Re: How to convert a Lazarus Project to Delphi 10
« Reply #1 on: March 04, 2021, 12:47:20 am »
  • Make a backup copy of your work. The following steps are destructive.
  • In the project settings select compilation mode DELPHI or DELPHI UNICODE ("Compiler options" > "Parsing" > "Syntax mode"). Delete the {$MODE objfpc}{$H+} from the header of each unit. Compile and test your program in this mode
  • Do not use typcial lazarus units: LCLIntf, LCLType, LMessages, use Windows and Messages instead.
  • Make a copy of the lpr file and name its extension dpr.
  • Remove the typical Unix header define from the lpr/dpr file. Remove unit Interfaces. Remove "RequireDerivedFormResource" and "Application.Scaled"
  • Make copies of each lfm file and rename them to have the extension .dfm
  • Open the .pas file associated to each lfm/dfm and replace the {$R *.lfm} by
Code: Pascal  [Select][+][-]
  1. {$IFDEF FPC}
  2.   {$R *.lfm}
  3. {$ELSE}
  4.   {$R *.dfm}
  5. {$ENDIF}
  • Load the dpr file into Delphi
  • Delete the form units from the uses clause and the lines in which the forms are created (Application.CreateForm)
  • Add the main unit to the project first, then add the other forms. There will be messages about incompatible properties. select "Ignore" or "Ignore all"
  • Save
The attached simple project was first created by Lazarus (folder laz) and then converted to Delphi by taking above steps (folder delphi). The project can be opened and compile by both Delphi (use dproj file) and Lazarus (use lpi file)

Of course, this is a simple project. Large projects will be much more difficult, often impossible. Usually the decision to migrate from Delphi to Lazarus is a one-way street.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamie

  • Hero Member
  • *****
  • Posts: 4362
Re: How to convert a Lazarus Project to Delphi 10
« Reply #2 on: March 04, 2021, 02:42:36 am »
I just completed a move of a project from Lazarus over to Delphi. it wasn't what I consider a super large project but it has ~20 medium sized units , some of which are forms..
 
  Started as a VC++ convert to Laz and ended as a Delphi project..

 I wouldn't suggest doing this to a large project unless you have too, even after the move over I still had to rebuild a few things that Delphi just wasn't going to adapt to..

 But its working ok now and things are compiling and linking fine..
The only true wisdom is knowing you know nothing

thehidden

  • Jr. Member
  • **
  • Posts: 73
  • Freelancer
Re: How to convert a Lazarus Project to Delphi 10
« Reply #3 on: March 04, 2021, 03:23:00 pm »
Thank you for the information.

I give one of my project to a friend, but she is using Delphi and not Lazarus...
I am mostly writing software for Image/Video based Process Documentation and Warehouse/Invoicing.
Other Software only if the project is interesting.

af0815

  • Hero Member
  • *****
  • Posts: 658
Re: How to convert a Lazarus Project to Delphi 10
« Reply #4 on: March 04, 2021, 08:08:04 pm »
She can install Lazarus side by side with Delphi. This is no problem
regards
Andreas

Leledumbo

  • Hero Member
  • *****
  • Posts: 8319
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to convert a Lazarus Project to Delphi 10
« Reply #5 on: March 05, 2021, 02:46:32 am »
No such a tool exists yet AFAIK. Often the needs is the other way around and Delphi is admittedly still a competitor. If such a tool exists, it should be written for Delphi instead of Lazarus. Language-wise, newer Delphi also introduces some breaking changes although FPC catches up some with compiler directives. Writing a newer Delphi compatible Lazarus project is harder then, and you don't really get something from porting Lazarus projects, as Lazarus supports many more platforms both as a host and a target than even the latest Delphi.

 

TinyPortal © 2005-2018