www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - If I use an extern (C) interface, can I use shared objects in Linux

reply "Bernard Helyer" <b.helyer gmail.com> writes:
I don't need to share GC memory across instances or anything,
but I would be interested in using a C interface if possible.

If not, what's blocking it. If yes, how would one initialise
the runtime? I know there's a Windows DLL article on the website,
but I'm interested in Linux.

I know GDC can do it for sure, but I'm interested in DMD's capabilities.



Thanks,
-Bernard.
Dec 02 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-12-02 15:13, Bernard Helyer wrote:
 I don't need to share GC memory across instances or anything,
 but I would be interested in using a C interface if possible.

 If not, what's blocking it. If yes, how would one initialise
 the runtime? I know there's a Windows DLL article on the website,
 but I'm interested in Linux.

 I know GDC can do it for sure, but I'm interested in DMD's capabilities.



 Thanks,
 -Bernard.

I'm not sure if DMD outputs PIC correctly. This has recently been fixed: http://d.puremagic.com/issues/show_bug.cgi?id=4583 Don't know if there's any other problem with PIC. I'm pretty sure that compiler needs to be changed to use a different model for TLS. There are a couple of different TLS models available. There's one model that works anywhere for everything, then there are also models that only works for statically linked applications or only for dynamically linked applications. I don't know which model DMD uses. The runtime also needs to be modified to make sure module infos, exception handling tables and TLS are implemented correctly. -- /Jacob Carlborg
Dec 04 2011