[fpc-pascal] Dynamic loading shared libraries
theo
xpde at theo.ch
Tue Aug 11 21:45:35 CEST 2009
> How would the easy way be?
>
I've just been looking into some old Kylix sources:
interface
const LibName = '';
function XftDrawCreate(display: PDisplay; win: XID; vis: PVisual;
colorm: longint): PXftDraw; cdecl;
implementation
function XftDrawCreate(display: PDisplay; win: XID; vis: PVisual;
colorm: longint): PXftDraw; cdecl; external LibName;
initialization
if dlopen('libXft.so', RTLD_LAZY or RTLD_GLOBAL) = nil then
I can't remember if the extra declaration in the interface section was
necessary.
But by simply settting Libname to empty string and using dlopen I could
switch from static do dynamic afair.
Thanks for the h2pas hint.
More information about the fpc-pascal
mailing list