dlang: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

时间:2015-08-14 22:47:45

标签: d

I'm trying to compile a simple hello world using dmd, but I get the following output:

dmd hi
/usr/bin/ld: hi.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
hi.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1

So I try with -fPIC then

/usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation R_X86_64_32 against `_D12TypeInfo_Aya6__initZ' can not be used when making a shared object; recompile with -fPIC
/usr/lib/libphobos2.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1

This was a non-existent problem a month or so ago.

System: Arch Linux 64bit.

What could possibly be the problem?

dmd -m32 hi
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when searching for -l:libphobos2.a
/usr/bin/ld: cannot find -l:libphobos2.a
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching for -lpthread
collect2: error: ld returned 1 exit status
--- errorlevel 1

1 个答案:

答案 0 :(得分:3)

发生此错误的原因是https://github.com/thestinger/hardening-wrapper存在加固包装。删除此包解决了这个问题。