www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Having trouble compiling D on Ubuntu 16.10

reply Dechcaudron <no-reply no-email.com> writes:
Hey there community,

some weeks ago I upgraded from 16.04 to 16.10, but it wasn't 
until now that I realized I can't develop with D anymore due to 
an error in the linking stage of the compilation process. dmd 
seems to be doing its job just fine, compiling with the -c flag 
does not produce any warnings or errors that should not be there. 
But when I move on to the linking stage with the instruction that 
dmd uses itself:

cc app.o -o app -m64 -L/usr/lib/x86_64-linux-gnu -Xlinker 
--export-dynamic -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic 
-lpthread -lm -lrt -ldl

I get a neverending ocean of errors that look pretty much all 
like these:

/usr/bin/ld: app.o: relocation R_X86_64_32 against symbol 
`__dmd_personality_v0' can not be used when making a shared 
object; recompile with -fPIC
/usr/bin/ld: 
/usr/lib/x86_64-linux-gnu/libphobos2.a(exception_24b_55a.o): 
relocation R_X86_64_32 against symbol `__dmd_personality_v0' can 
not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 
/usr/lib/x86_64-linux-gnu/libphobos2.a(exception_24c_3b4.o): 
relocation R_X86_64_32 against symbol `__dmd_personality_v0' can 
not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: 
/usr/lib/x86_64-linux-gnu/libphobos2.a(exception_24f_4a2.o): 
relocation R_X86_64_32 against symbol `__dmd_personality_v0' can 
not be used when making a shared object; recompile with -fPIC

Anybody has any idea why this is happening? Is the only solution 
to downgrade to Ubuntu 16.04 to be able to work in the meantime?

Thanks beforehand :)
Oct 30 2016
parent reply Mike Parker <aldacron gmail.com> writes:
On Sunday, 30 October 2016 at 11:25:30 UTC, Dechcaudron wrote:


 Anybody has any idea why this is happening? Is the only 
 solution to downgrade to Ubuntu 16.04 to be able to work in the 
 meantime?

 Thanks beforehand :)
Try adding `-fPIC -defaultlib=libphobos2.so` to your dmd.conf. And see the following links: http://forum.dlang.org/thread/tppsgztsbsdrtkpcbtak forum.dlang.org https://issues.dlang.org/show_bug.cgi?id=5278
Oct 30 2016
parent Dechcaudron <no-reply no-email.com> writes:
On Sunday, 30 October 2016 at 11:40:01 UTC, Mike Parker wrote:
 On Sunday, 30 October 2016 at 11:25:30 UTC, Dechcaudron wrote:


 Anybody has any idea why this is happening? Is the only 
 solution to downgrade to Ubuntu 16.04 to be able to work in 
 the meantime?

 Thanks beforehand :)
Try adding `-fPIC -defaultlib=libphobos2.so` to your dmd.conf. And see the following links: http://forum.dlang.org/thread/tppsgztsbsdrtkpcbtak forum.dlang.org https://issues.dlang.org/show_bug.cgi?id=5278
Thanks Mike, changing dmd.config did the trick. I'll learn the details from the discussion you linked.
Oct 30 2016