status of shared libs

Martin Nowak code at dawg.eu
Tue Apr 9 08:51:40 PDT 2013


On 04/08/2013 08:00 PM, Rainer Schuetze wrote:
>
>
> On 07.04.2013 17:19, Martin Nowak wrote:
>> On 04/07/2013 10:21 AM, Jacob Carlborg wrote:
>>> On 2013-04-07 04:15, Ellery Newcomer wrote:
>>> I think it needs weak linkage or similar. I don't know if it's possible
>>> to do in D, but in C it can be done like this:
>>>
>>> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dylib_fixes.c
>>>
>>>
>>>
>>>
>> Yes, druntime should only weakly link against _Dmain.
>>
>
> I think the correct way is to remove the C main function from dmain2.d
> and put it in an extra library to be linked with the executable. At
> least on Windows, you won't be able to link back from the DLL to the
> main executable.

I think the best way is to sythesize a main function in the executable.
Something like this.

extern(C) int main(int argc, char** argv)
{
   rt_init(argc, argv);
   runMain(&_Dmain);
   return rt_term();
}


More information about the Digitalmars-d mailing list