from the news pages about how to do organise the calls from C to D.
Define a function called _init():
It will be called when the .so is loaded, just like DllMain. There's a _fini() function for unload time. "man dlopen" for details. It works even if you are not doing dynamic loading with dlopen()!
According to the compiler page, DMD can't handle shared libraries. Are you using GDC?
To run D as a dynamic library under Linux it is necessary to use GDC.