[Lazarus] RE : RE : RE : RE : Imposible call DLL (dylib) in Mac OSX Lion

Ludo Brands ludo.brands at free.fr
Sun Aug 7 20:11:44 CEST 2011


 

It went all right with dynamic loading. "liknlib" gives me and error in
linking time. So I think runtime loading of dll is better. What I don't know
is what it's necessary rename functions with "_" at starting in Mac. Is it a
bug?
Regards.
Juan.

It is not a bug. dlsym, the function used to find the address assumes C type
of function names which are prefixed with _. Pascal doesn't prefix exported
functions with _. See
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa
ges/man3/dlsym.3.html, down the page, notes.
 

To make porting easier you can use the alias modifier with $ifdef like this:
 
function DllMessage(): Longint; {$ifdef darwin} alias : '_DllMessage';
{$endif}
...
exports DllMessage;
 
This way, the function will be exported as  _DllMessage on Darwin only,
DllMessage on other platforms.
 
Ludo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110807/5010d71a/attachment-0003.html>


More information about the Lazarus mailing list