DSO with DMD 2.052 on Linux?

Kai Meyer kai at unixlords.com
Mon May 2 14:19:38 PDT 2011


On 05/02/2011 03:10 PM, Jonathan M Davis wrote:
>> Is dynamic linking supported on Linux with DMD 2.052 (and D2 in general)?
>>
>> I am not talking about Phobos, just modules which I want to compile as DSO.
>>
>> There is -fPIC switch to DMD - does it work as intended?
>>
>> PS: gdc is not an option...
>
> The short answer: no.
>
> As for the long answer, someone else could answer far better than I could.
> IIRC, the main problem is the runtime. It has issues when you try and split
> your D code with .so files (I believe that you end up with multiple instances
> of the runtime). It _might_ work if you don't use the garbage collector at
> all, but there could be other issues. I don't remember exactly what all of the
> problems are. But regardless, don't expect shared libraries to work at the
> moment.
>
> Getting shared libraries to work is near the top of the TODO list, but it
> hasn't been done yet.
>
> - Jonathan M Davis

I thought I saw somewhere that you simply have to have the runtime 
initialized before calling into the shared library (which is done for 
you when dmd is supposed to produce an executable):

http://www.digitalmars.com/d/2.0/phobos/core_runtime.html

I may be incorrect too :)

-Kai Meyer


More information about the Digitalmars-d mailing list