Recent

Author Topic: porting a utility DLL from Windows to Linux  (Read 4014 times)

jaspers

  • Newbie
  • Posts: 1
porting a utility DLL from Windows to Linux
« on: February 19, 2014, 05:48:29 pm »
Hey, all, I'm a total newbie to lazarus but have been a delphi programmer for years.  Please forgive me if i'm asking a FAQ or missing something obvious, or if this is the wrong board to post on.

I'm on Ubuntu Linux (13.10) with Lazarus 1.0.14 .deb and FPC 2.6.2 downloaded and installed from the Lazarus project itself (not the .debs from repo).

I'm trying to convert and compile a Delphi project in Linux.  It was non-visual: just some utilities that were .DLLs on Windows.

The first thing I'm hitting is that the unit uses Windows so I get the following error:

Code: [Select]
MLRIBMemUnit.pas(7,6) Fatal: Can not find unit Windows used by MLRIBMemUnit.
Is there an equivalent Lazarus package for this?  Or is "uses Windows;" usually a lost cause?  Or do I comment it out and then try to address / rewrite each of the actual functions that are called?

Taking the last strategy, for instance: when I comment it out, I get undefined functions ( "Error: Identifier not found") for:
TlsSetValue
TlsGetValue
DLL_THREAD_DETACH
DllProc
TlsAlloc
RaiseLastWin32Error
TlsFree

..and it stops after 9 errors..

Any recommendations on how to proceed at this point?

Or is there a "porting Delphi to Lazarus" post or guide anywhere that might help?

Or a table of equivalent Delphi <-> Lazarus units?

Thanks for any help/suggestions..
« Last Edit: February 19, 2014, 05:57:32 pm by jaspers »

howardpc

  • Hero Member
  • *****
  • Posts: 3177
Re: porting a utility DLL from Windows to Linux
« Reply #1 on: February 19, 2014, 07:03:24 pm »
You know there are options on the Tools menu for converting Delphi units and/or projects?

You may find it easier to port your Delphi project to Lazarus on Windows first. The Delphi project converter does a pretty good job if you just leave the default settings alone, and it will save an unchanged backup copy of your Delphi files.

Once you've got your converted project running under Lazarus on Windows, then take that code to Linux to iron out specific Windows-isms that you may need to tweak manually.
The tlsXXX thread calls are available in the FPC RTL (already ported).
However, the "mem" in your unit name does raise the question whether the Delphi project is tied specifically somehow to Delphi's memory manager.

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: porting a utility DLL from Windows to Linux
« Reply #2 on: February 19, 2014, 08:16:12 pm »
The tlsXXX thread calls are available in the FPC RTL (already ported).
For some reason I can't find them. Can you tell me which unit? I used Find in Files but the results were related to Windows. I believe these are the FPC RTL docs on line.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7500
Re: porting a utility DLL from Windows to Linux
« Reply #3 on: February 19, 2014, 09:45:34 pm »
Unit Windows is the main Windows header. It is not portable.

Best solution is to get the application working with Windows first, and minimize dependencies on target dependent units.

FPC has native TLS support (threadvar), so the tls* functions might not be necessary.