[fpc-devel] a shared library suggestion

peter green plugwash at P10Link.net
Wed May 10 02:15:17 CEST 2006


yeah that technique requires far less stubs but it means that the coder has
to manually call an init function.

also how does your code respond if one of the entry points isn't found?

> -----Original Message-----
> From: fpc-devel-bounces at lists.freepascal.org
> [mailto:fpc-devel-bounces at lists.freepascal.org]On Behalf Of Joost van
> der Sluis
> Sent: 09 May 2006 23:26
> To: FPC developers' list
> Subject: RE: [fpc-devel] a shared library suggestion
>
>
> On Tue, 2006-05-09 at 21:26 +0100, peter green wrote:
> > > > What i'd like to see is compiler level support for loading
> > > dynamic libraries
> > > > and binding thier functions on demand.
> > >
> > > Like the database-base packages do? (example:
> > > packages/base/ibase/ibase60dyn.pp)
> > ok that unit really confuses me, it seems to treat procedures declared
> > external as if they were pointers. what exactly is going on?!
>
> It defines the procedures as variables, like this:
>
> var
>   isc_attach_database : function(param:integer):integer; extdecl;
>
> And then it assigns the external-procedure to it - at runtime - with
> this commands:
>
> begin
>   IBaseLibraryHandle:=LoadLibrary(LibraryName);
>   pointer(isc_attach_database) :=
>      GetProcedureAddress(IBaseLibraryHandle,'isc_attach_database');
> end;
>
> And when that is done, you can simply call:
>
> i := isc_attach_database(param);
>
> Maybe you could get confused by the ifdef's and 'extdecl' term.
> 'extdecl' is just a macro defined as cdecl or stdcall, dependent on the
> OS.
>
> And the include-file can be used for dynamical loading, and statical. So
> all proceduress are defined twice. Once statical and once dynamical.
> Which one is compiled is dependent on the LinkDynamically define.
>
> Joost.
>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list