On 3/23/2011 3:22 AM, Dainius (GreatEmerald) wrote:
Though I find it quite odd that I need workarounds like those to
compile on Linux, but ah well, it works, at least. Also odd that I
can't link using GCC on Linux, it gives me a long list of undefined
references (it seems that they are all coming from phobos2, it's here
if you wish to look through it: http://pastebin.com/cfyMDzDn ). But
once again, at least it works now, so thanks a lot!

The weird linking with Linux appears to be caused by DMD requiring symbols for thread local storage. When you declare main, DMD will output those symbols. I don't know of any other way to get those symbols.

int function() _main = &main; // Makes DMD output the _tls symbols.

Your issue when linking with GCC looks like your missing the pthread library or development files.

gcc cpart.o -o cpart -m32 -Xlinker -L/home/venix/dmd2/linux/bin/../lib32 -Xlinker -L/home/venix/dmd2/linux/bin/../lib64 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt dpart.a -lphobos2 **-lpthread** -lm


Something a little more cosmetic, would be to have the D library call rt_init and rt_term. That could be automatic with a shared library. With a static library having Library_Init and Library_Quit do it would work.

Reply via email to