Dynamic libraries, again

Walter Bright newshound1 at digitalmars.com
Sun Mar 14 15:36:19 PDT 2010


Jacob Carlborg wrote:
> I've been working the whole day on getting Tango to work built as a 
> dynamic library with dmd on Mac OS X. I have one problem (for now) that 
> I can't seem to solve.
> 
> The problem is that the module constructors are not called. That is 
> because the module info array in the object module, which contains all 
> the module constructors that should be called, is (almost) empty. It 
> seems like that the compiler or the linker doesn't put the module 
> constructors that are dynamically linked into the executable. I've also 
> tried to move the _minfo_beg and _minfo_end variables, which are the 
> beginning and the end of the sections containing the module info array, 
> from the object module to a statically linked module and then passed 
> them as arguments to the _moduleCtor function but without any success.
> 
> Does anyone have any idea have to solve the above problem? Does the 
> compiler need to be modified?

There will be an _minfo_beg and _minfo_end for each loaded shared 
library. These must then be combined at runtime to form an aggregate 
array of all the modules.

I don't know how to search the shared libraries to find the 
_minfo_beg/end sections, though I've never researched it, either.



More information about the Digitalmars-d mailing list