[fpc-pascal] Shared libries

Torsten Bonde Christiansen tc at epidata.dk
Sun Dec 11 23:18:01 CET 2011


On 2011-12-11 22:57, ik wrote:
> On Sun, Dec 11, 2011 at 23:35, Torsten Bonde Christiansen 
> <tc at epidata.dk <mailto:tc at epidata.dk>> wrote:
>
>     Hi.
>
>     I'm trying to create a shared library (under linux) and I not sure
>     what the
>     difference between the modifier *export* and the section *exports*
>     is? Or perhaps
>     when to use one and the other...
>
>
> export means that you can control the name of a symbol in how it will 
> be in the elf file itself of the so.
> So you call your original procedure Foo, but you export it as 'baz', 
> so using objdump in Linux, you'll find "baz" and not "Foo".
>
> Exports, is the way to tell the compiler what are the symbols you wish 
> to make available for reuse in the so file itself, so I could bind to 
> them.
So in the following example "foo" would not be visible (neither as "foo" 
nor "bar") to other program (eg. a C-program) unless I added an 
*exports* section?

library test;

function foo(a: integer): integer; [export, alias: 'bar'];
begin
   result := a * a;
end;

end.


Basically what i'm trying to do, is use a lot of units and I want avoid 
creating a HUGE *exports* section but rather name the
methods in the units instead.

Regards,
Torsten Bonde Christiansen.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111211/cdef2495/attachment.html>


More information about the fpc-pascal mailing list