On Sunday, 8 April 2012 at 08:45:46 UTC, Timo Westkämper wrote:
        dmd -g -c test.d -fPIC
        ld -shared -o libtest.so test.o -lrt -lphobos2 -lpthread
        gcc -g main.c -ldl -lpthread

Hmm, wouldn't using DMD directly for the first two compilation steps do the same thing, just faster and simpler? Like this:

    dmd -shared -fPIC test.d

Although in my tests, it always gives me an error like this, no matter which way I try to compile it:

ld: /usr/lib64/libphobos2.a(lifetime_368_548.o): relocation R_X86_64_32 against `_D15TypeInfo_Shared7__ClassZ' can not be used when making a shared object; recompile with -fPIC
    /usr/lib64/libphobos2.a: could not read symbols: Bad value

Though this is still with DMD v2.058, so perhaps there were some changes with this in the latest version. Or I'm missing something.

By the way, what is the status of D shared libraries on Windows?

Reply via email to