status of shared libs

Jacob Carlborg doob at me.com
Sun Apr 7 01:21:08 PDT 2013


On 2013-04-07 04:15, Ellery Newcomer wrote:

> trying out the spiffy new shared lib support, I get this:
>
> 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?

It's declared in druntime and therefore expected to be included:

https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L348

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

Don't know if that is compiled and linked. There probably needs to be a 
way to exclude the C main function as well.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list