Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-05

Linux loadlibrary vs Windows

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tony Maro

I use the Synapse TCP toolkit. I recently updated to 2.0.2 (can't get a full working 2.0.3 in Windows yet for some reason) and found that Synapse suddenly didn't compile in Linux.

Now, it's likely that the Synapse toolkit has already been updated, but my point is the difference now between Linux and Windows. Previously the same code worked, but now you have to remove the pointer(*) typecast from Linux, but it still had to be there for Windows.

Was this intentional? Both compilers (Linux and Win32) are running 2.0.2 now.

Here's what I had to do to the Synapse toolkit:

function FreeLibrary(Module: HMODULE): LongBool;
begin
  {$ifdef linux}
  Result := dynlibs.UnloadLibrary(Module);
  {$else}
  Result := dynlibs.UnloadLibrary(pointer(Module));
  {$endif}
end;
function GetProcAddress(Module: HMODULE; Proc: PChar): Pointer;
begin
  {$ifdef linux}
  Result := dynlibs.GetProcedureAddress(Module, Proc);
  {$else}
  Result := dynlibs.GetProcedureAddress(pointer(Module), Proc);
  {$endif}
end;

Reply by email

Marco van de Voort
to Tony Maro
Show quoted text 10 lines
I use the Synapse TCP toolkit. I recently updated to 2.0.2 (can't get a full working 2.0.3 in Windows yet for some reason) and found that Synapse suddenly didn't compile in Linux. Now, it's likely that the Synapse toolkit has already been updated, but my point is the difference now between Linux and Windows. Previously the same code worked, but now you have to remove the pointer(*) typecast from Linux, but it still had to be there for Windows. Was this intentional?

If it worked, it was a coincidence. This because unit dynlibs specifies "tlibhandle" as library handle. There are some cludges that define a type "HMODULE" as type, but that might break, e.g. when unit Windows is included before dynlibs, or some other unit that defines it.

Reply by email

Michael Van Canneyt
to Tony Maro: I use the Synapse TCP toolkit. I recently updated to 2.0.2 (can't get a full working…
Tony Maro wrote 31 lines
I use the Synapse TCP toolkit. I recently updated to 2.0.2 (can't get a full working 2.0.3 in Windows yet for some reason) and found that Synapse suddenly didn't compile in Linux. Now, it's likely that the Synapse toolkit has already been updated, but my point is the difference now between Linux and Windows. Previously the same code worked, but now you have to remove the pointer(*) typecast from Linux, but it still had to be there for Windows. Was this intentional? Both compilers (Linux and Win32) are running 2.0.2 now. Here's what I had to do to the Synapse toolkit: function FreeLibrary(Module: HMODULE): LongBool; begin {$ifdef linux} Result := dynlibs.UnloadLibrary(Module); {$else} Result := dynlibs.UnloadLibrary(pointer(Module)); {$endif} end; function GetProcAddress(Module: HMODULE; Proc: PChar): Pointer; begin {$ifdef linux} Result := dynlibs.GetProcedureAddress(Module, Proc); {$else} Result := dynlibs.GetProcedureAddress(pointer(Module), Proc); {$endif} end;

AFAIK this has been fixed in the Synapse toolkit.
It has been changed to use the agnostic TLibHandle type.

Michael.

Reply by email

Tony Maro
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
AFAIK this has been fixed in the Synapse toolkit. It has been changed to use the agnostic TLibHandle type.

Okay, thanks. I just thought it was odd that it worked the same for both and then in a later FPC it didn't.

One day I must update my synapse toolkit too ;-)

-Tony

Reply by email