status of shared libs

Maxim Fomin maxim at maxim-fomin.ru
Mon Apr 8 05:48:25 PDT 2013


On Monday, 8 April 2013 at 04:16:20 UTC, Walter Bright wrote:
> On 4/7/2013 6:14 PM, Ellery Newcomer wrote:
>> On Sunday, 7 April 2013 at 06:03:38 UTC, Walter Bright wrote:
>>> On 4/6/2013 7:15 PM, Ellery Newcomer wrote:
>>>> dmd  -unittest -fPIC -defaultlib=phobos2so -shared test1.d 
>>>> -oflibtest1.so
>>>> gcc  test1.c `pwd`/libtest1.so -L/usr/lib64/dmd/ 
>>>> -L/usr/lib/dmd/ -o test1.x
>>>> /lib64/libphobos2so.so: undefined reference to `_Dmain'
>>>> collect2: error: ld returned 1 exit status
>>>>
>>>>
>>>> _Dmain? wat?
>>>
>>> _Dmain is the mangled name for main() in your program.
>>
>> Yes, I know, but does it make sense to provide it when I call 
>> my shared lib from C?
>
> Currently, I think you'll need a D main().

I think there is no need for D main and it can be fixed simply by 
defining _Dmain() in druntime. If user defines _Dmain() somewhere 
in his code, it would be caught by linker, if not the behavior 
would depend on druntime version. Advantage is that there would 
be no building errors (may be except when _deh_beg and _deh_end 
are required), the question is what to do in default version - 
silently ignore or throw error.


More information about the Digitalmars-d mailing list