shared libraries in D

Johannes Pfau spam at example.com
Tue Feb 15 07:02:20 PST 2011


Iain Buclaw wrote:
>Came across this obscure documentation in the tldp.
>
>"Libraries should export initialization and cleanup routines using the
>gcc __attribute__((constructor)) and __attribute__((destructor))
>function attributes."
>
>This is what gdc was doing anyway.
>
>
>"Constructor routines are executed before dlopen returns (or before
>main() is started if the library is loaded at load time). Destructor
>routines are executed before dlclose returns (or after exit() or
>completion of main() if the library is loaded at load time)."
>
>This is what should have been happening, but wasn't earlier because:
>
>
>"Shared libraries must not be compiled with the gcc arguments
>`-nostartfiles' or `-nostdlib'. If those arguments are used, the
>constructor/destructor routines will not be executed (unless special
>measures are taken)."
>
>Whoops! Fixed and it now works. :~)
>
>Will be making shared libraries default in GDC pretty soon now...

Great, now I've got 2 questions:

1.) Are shared libraries compiled with gdc abi compitible with dmd?
(if dmd did support shared libraries)

2.) Is it now possible to load a shared d library into a C program? Will
jut loading the library initialize the runtime or is it necessary to
call some runtime setup functions manually? If the C program loads 2 D
libraries, will those share the gc/runtime?

-- 
Johannes Pfau
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110215/96a0a9d0/attachment.pgp>


More information about the Digitalmars-d mailing list