Sunday, July 20, 2008

Migratin from Delphi to Lazarus

Not to me on time, even to this boring, but again I got a challenge on my shoulders is really difficult to meet.

The fact is migrating an application to Delphi Lazarus is easy, by the way, but specifically this beautiful Delphi library im wornking on make a heavy use of Windows API messages...

Reviewing the steps to begin to migrate an application to Delphi Lazarus are very simple.

1) Create a new structure, independent of the one containing the Delphi application, so that you touches does not affect your Delphi application (is basic but very few do it).
2) For each Delphi project file (only for the dpr)

makepasx Proyect1.dpr

3) For each .pas file executes the following command

makepasx unit1.pas

4) For each delphi form execute this command

dfmtolfm unit1.dfm

5) Lazarus uses a resource file for each form, with extension lrs. To generate:

lazres unit1.lrs unit1.lfm lazres unit1.lrs unit1.lfm

Made. We already have everything we need to take the first step in our journey of 1000 miles (the more important).Now just compile and see what happens.

Usually some functions or calls vary somewhat between Delphi and Lazarus. It could put some of them here, but it makes no sense because they are many. Instead I will give you a way to resolve discrepancies in the simplest way, or by various methods that generally make me reach the correct result:

1) If you can not find an identifier or method just look in the sources references in the sources of Lazarus. Sounds silly? Is the simplest way, this way you can know that unit is defined and objects that use it.

2) If the identifier or method does not exist in lazarus, go to the forums Lazarus and looking for. Sure someone before you crash with that stone and found how to setp out ;)

3) If none of that works, the friend google comes to the rescue. You might try Lazarus discrepantname or add the word replacement, and so on.

Finally, as the case may happen in the library that attempt to migrate, that there are too many calls to the Windows API. In this case point 2 and 3 are generally much help.

4) Subscribe to groups Lazarus and fpc. Who better than those who have already been there can help you? Even if a feature is not suported they will help you to implement it and produce the miracle of Lazarus and fpc library get enriched. :)

In other deliveries i will comment about my progress in the conversion and as the problems were resolved.

Namaste.

2 comments:

Reenen said...

Or go to irc://irc.freenode.com to #lazarus-ide or #fpc.

There are lots of friendly people who gladly help (and it's pretty quick too).

Reenen said...

irc.freenode.org I think actually...