On Wednesday, 9 July 2014 at 21:30:45 UTC, Pavel wrote:
Hello!
I've reproduced steps 1-9 on my Ubuntu 14.04 x64 machine, but
now I have this errors:
root@dlang:~/phpext# dmd -shared speedup_wrap.o dfakemain.o
speedup.o -ofspeedup.so
/usr/bin/ld:
/usr/lib/x86_64-linux-gnu/libphobos2.a(lifetime_485_6c8.o):
relocation R_X86_64_32 against `_D15TypeInfo_Shared7__ClassZ'
can not be used when making a shared object; recompile with
-fPIC
/usr/lib/x86_64-linux-gnu/libphobos2.a: error adding symbols:
Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1
I'm new to D/C languages, so what can I do to fix this error? I
tried to compile with "-fPIC" option at all appropriate steps,
but nothing helps :(
I think Rémy's advice is a little outdated when dealing with
shared libraries, which are now supported on linux, so the fake
main is not necessary there anymore:
http://dlang.org/dll-linux.html#dso7
Try linking to phobos as a shared library as shown there and then
calling the D function, I believe it should work (you'll also
need to call rt_init() before the D library and rt_term() after).