www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GDC is this a bug or a feature?

reply Russel Winder <russel winder.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


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


--=20
Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
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
Nov 11 2012
parent "RenatoUtsch" <renatoutsch gmail.com> writes:
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.
Nov 11 2012