External library name

Hairy Pixels via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <CAGsUGtm0rnKOr6MK90Ldsf4MXQ7omMhpxh5vtJ2yua7RPepLGA@mail.gmail.com>
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

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.