Answer the question
In order to leave comments, you need to log in
Shared library on D?
Is there a way to build .so on D cross-platform?
At the moment, I encountered the fact that on one machine (ubuntu 12.04, x86) it is assembled, and moreover, it fully works, but on the other (the same OS, x86-64) it does not.
I collect like this:
dmd -c -fPIC test.d -I. -J.
gcc test.o -shared -lrt -lpthread -lphobos2 -o libtest.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libphobos2.a(minfo.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libphobos2.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [test] Ошибка 1<br>
Answer the question
In order to leave comments, you need to log in
If they don’t answer here, you should write directly to the mailing list of this compiler, they should definitely know there.
It looks like -fPIC is simply ignored by the compiler.
On x86 it is possible to build shared libs without -fPIC. On x86_64, no.
The solution was to build druntime and phobos themselves manually with the gcc and dmd -fPIC options enabled. I made a pull request with patched makefiles to the official repository, let's see if they will accept it, but I collected everything at home, thanks to everyone.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question