[fpc-pascal] Free Pascal created libraries used by other languages
Michael Van Canneyt
michael at freepascal.org
Wed Dec 9 15:16:53 CET 2009
On Wed, 9 Dec 2009, Marco van de Voort wrote:
> In our previous episode, Graeme Geldenhuys said:
>>> 2. Since FPGui is object oriented, it will be unusable unless you devise
>>> a 'flat' API.
>>
>> Is't there a way the FPC compiler can automatically flatten object oriented
>> code?
>
> No.
>
>> As a test I created a new library project and included the
>> fpgui_toolkit.pas unit which contains references to all units available in
>> fpGUI Toolkit. I had to add the -fPIC compiler parameter and in
>> successfully compiled a fpgui_toolkit.so file.
>
> You got a .so file. How do you know it is correct?
>
>> I know I can't use that file, because no functions have been exported. But
>> viewing the .so file with Midnight Commander (pressing F3) shows me what
>> looks like a 100% flattened API of fpGUI Toolkit - it's probably debug
>> information. But doesn't that mean the compiler could also do something
>> similar an instead generate exported methods (flattened API).
>
> You see mangled names, exactly what you would see if you did this on a C++
> .so. IOW this dll is not flattened.
>
> Do this on a C dll to see the difference.
>
> Roughly there are only three options:
> - wait for packages support
> - implement packages support
> - export a C api (more or less as Jonas said), and take the more difficult
> usage (and need to rewrap if you want OO interface) for granted.
>
> Reread the wiki entry to get an idea what packages are about.
I could not say it more concise as this, Marco wrapped it up nicely.
Michael.
More information about the fpc-pascal
mailing list