[fpc-pascal] Dynamic loading shared libraries

Florian Klaempfl florian at freepascal.org
Tue Aug 11 21:25:11 CEST 2009


theo schrieb:
> 
>> 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.

Yes, this was possible with Kylix, however, it requires the usage of PIC
also inside the caller.



More information about the fpc-pascal mailing list