[fpc-pascal] bridging an C++ shared library statically

Michael Van Canneyt michael at freepascal.org
Sat Sep 21 16:20:01 CEST 2013



On Sat, 21 Sep 2013, Xiangrong Fang wrote:

> Hi All,
> 
> I need to use a C++ so file in FreePascal.   I have written a C wrapper for it, which successfully connected to Pascal.
> 
> Now my question is, can I use the $linklib directive to link the C-Wrapper STATICALLY, which in-turn use the shared so file?   I tried to do this but it complained a lot of
> undefined references.

This is normal.

> 
> The key problem is, the {$linklib} instruction only tell FPC where to look for external functions in the C Wrapper, but how can I tell the linker to look for the ORIGINAL C++
> so file to look for symbols required but not defined in the C-Wrapper?

{$linklib XYZ}

can be used for any library. So you should add the C wrapper library, C++ library,
and probably some others as well, such as the C++ STL.

Michael.


More information about the fpc-pascal mailing list