[fpc-pascal] linking to a shared library (linux platform)
Alain Michaud
Alain.Michaud at nrc-cnrc.gc.ca
Tue Jan 3 23:58:26 CET 2006
Hi everyone,
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":
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!
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 would apreciate if someone could put me back on the track please!
In order to indicate my level of knowledge, I should mention that so far
I could:
1-load the library using "dlopen": error code showed "no error"
2-locate the function using "dlsym": error code showed "no error"
3-made sure that the library is well installed by compiling and running
a small C language demo program.
Thank you for reading.
Happy new year
Alain Michaud
amiso
More information about the fpc-pascal
mailing list