[fpc-pascal] linking to a shared library (linux platform)

Marco van de Voort marcov at stack.nl
Wed Jan 4 08:50:07 CET 2006

> I would appreciate some advice about the following (I try to be clear
> and short!):
> I am trying to dynamically link a shared library ("libplot.so" from the
> package: www.gnu.org/software/plotutils ). I do this using "dlopen" and
> "dlsym". Usually it works very well but this time, I do not understand
> the "C" prototype in the header file "plot.h":

(don't, use unit dynlibs that wrap those)
> plPlotterParams * pl_newplparams (void)

> The function "pl_newplparams" is supposed create a structure (record)
> and then return some "pointer" to it. The user is not supposed to access
> this data directly, so there is NO reference to "plPlotterParams" al all
> in the header files (plot.h)! How does the C compiler knows what
> plPlotterParams is then?
> It just assumes it is a pointer or it looks
> into the liplot.so file directly? To me this is a mistery

No idea, I assume that if it is named it must be declared somewhere. However
it doesn't really matter if you don't use it, any pointer type will do
> I now that dlsym will search for the procedure names in the library, but
> do I have to do that for plPlotterParams as well?
> If not, then what type should I use for the return parameter: Pointer?
> integer? I get an exception as soon as I call the routine. (other
> routines with simple return types works well of course) 

I usually use a pointer to an empty record.

More information about the fpc-pascal mailing list