November 11, 2012 GDC is this a bug or a feature? | ||||
---|---|---|---|---|
| ||||
Attachments:
| |> 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 -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
November 11, 2012 Re: GDC is this a bug or a feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | 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.
|
Copyright © 1999-2021 by the D Language Foundation