On Sunday, 11 November 2012 at 10:39:41 UTC, Russel Winder wrote:

|> gdc -o lib_helloWorld.so -shared helloWorld.os
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.6/libgphobos2.a(object_.o): relocation R_X86_64_32S against `_D11TypeInfo_Pv6__initZ' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-linux-gnu/4.6/libgphobos2.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

I've had the same problem when trying to compile a shared library, but with dmd.

It turned out that to make a shared library you can't use phobos dependencies because it isn't ready to work with shared libraries. Indeed, if you remove any phobos dependencies, the shared library is compiled successfully.

Well, that's the noob explanation, I don't know the details of why phobos doesn't work. My bet is that it is shipped as a static library, and (if I'm not wrong) you can't link a static library on a shared library...

Still, that is a big problem that D has.

Reply via email to