Problems with shared library (-fPIC) and tango
e-t172
e-t172 at akegroup.org
Sat Jul 5 04:51:16 PDT 2008
Marius Muja a écrit :
> I'm working on a project that needs to be compiled both as a standalone
> executable and (part of it) as a shared library. It's been working like
> that on 32 bit machines without any problems, but now I need to compile
> it on a 64 bit machine (to be able to access more the 3GB of memory).
>
> When I tried to build the project on the 64 bit machine I was unable to
> build the shared library because of the following error:
>
> libgphobos.a(ti_AC.o): relocation R_X86_64_32 against
> `_D17TypeInfo_C6Object6__initZ' can not be used when making a shared
> object; recompile with -fPIC
You can build a D shared library without including Tango in it (there
will be undefined references in the shared library, which will be
resolved when Tango is linked with the main executable).
If you're using GDC, use the -nophoboslib switch when creating your
shared library to avoid linking to Tango.
Some problems can occur, though. If you happen to modify your shared
library in such a way that the library makes use of a Tango symbol it
didn't use before, it won't work unless you relink your executable to
include the new symbol. That kind of defeats the whole purpose of having
shared libraries. Of course, one could include all Tango symbols in the
executable to solve the problem, but then you will end with a huge
executable because all Tango will be included in it.
More information about the Digitalmars-d
mailing list