Equivalent of DllMain on OSX?
Joakim via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 25 16:23:04 PDT 2014
On Friday, 25 July 2014 at 21:23:00 UTC, Mark Isaacson wrote:
> I am presently trying to port a driver I wrote for Windows to
> OSX. The one thing standing in my way is figuring out how to
> get the equivalent of DllMain on OSX.
>
> I need a place to call Runtime.initialize() and whatnot.
>
> Reading the wiki, it seemed like `shared static this()` was
> the appropriate construct to use, and indeed, when I run the
> test program from:
> http://dlang.org/dll-linux.html#dso9
>
> I get the desired results: namely, I see that the `shared
> static this()` in that test program is called the desired point.
>
> When I try the same thing in my driver, it is never executed.
>
> Are dylibs on OSX not supported still (I saw some very old
> threads from 2012 stating as much)? Does it matter that I have
> multiple modules in the driver? Any help would be appreciated.
>
> I shall endeavor to get the modified driver code into a state
> where I can link it as well.
Loading multiple D shared libraries isn't supported on OS X yet,
see these warnings in druntime:
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/sections_osx.d#L198
If you only have a single D shared library, I think it's
possible, you just may have to tweak dmd/druntime or your build
process a bit.
I think Martin Nowak or Jacob Carlborg can really answer your
questions, as Martin wrote a lot of that code and Jacob seems to
follow it closely, whereas I don't use OS X but looked at that
code when porting to Android.
More information about the Digitalmars-d-learn
mailing list