[fpc-pascal] External library name
Hairy Pixels
genericptr at gmail.com
Sun Jan 5 04:09:40 CET 2025
I see this pattern in C translated header often but I’ve honestly never
understood it entirely.
Why does this “cDllName" need to be added to every single function which
you could just use {$linklib xxxx}?
Furthermore, I’m not even aware that it’s possible to tell the linker that
you want to search for a specific symbol in a specific library so I wonder
does the external library name actually do anything or does it just call
{$linklib} behind the scenes? I’m on macOS and I don’t know how the linkers
work on other platforms so maybe that’s relevant too.
============================================================
const
cDllName = {$IFDEF WINDOWS}
{$IFDEF DEBUG}
{$IFDEF WIN64} 'libraylib64-debug.dll' {$ELSE}
'libraylib32-debug.dll' {$ENDIF}
{$ELSE}
{$IFDEF WIN64} 'libraylib64.dll' {$ELSE}
'libraylib32.dll' {$ENDIF}
{$ENDIF}
{$IFEND}
{$IFDEF DARWIN} 'libraylib.dylib' {$IFEND}
{$IFDEF LINUX} 'libraylib.so' {$IFEND};
procedure InitWindow(aWidth : Integer; aHeight : Integer; aTitle :
PAnsiChar); cdecl; external cDllName;
function WindowShouldClose() : Boolean; cdecl; external cDllName;
procedure CloseWindow(); cdecl; external cDllName;
Regards,
Ryan Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20250104/c67a17ff/attachment.htm>
More information about the fpc-pascal
mailing list