DMD Fails with fPIC error

Mike Wey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 14 03:48:06 PDT 2014


On 06/14/2014 03:58 AM, Reuben wrote:
> Hi,
> I'm new to D and am trying to compile a simple hello world program.
> I get the following error when compiling it:
>
>> dmd test.d
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
> /opt/dmd-2.065/lib64/libphobos2.a(lifetime_488_4cd.o): relocation
> R_X86_64_32 against `_D15TypeInfo_Shared7__ClassZ' can not be used when
> making a shared object; recompile with -fPIC
> /opt/dmd-2.065/lib64/libphobos2.a: could not read symbols: Bad value
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
>
> This error occurs regardless of whether I use the -fPIC option or not.
> Compiling DMD from source does not change anything.
>
> I am using DMD 2.065.0 on Sabayon amd64, compiled from the dlang overlay
> with gcc (Gentoo Hardened 4.7.3-r1 p1.4, pie-0.5.5) 4.7.3.
>
> Thanks in advance.

 From the error it looks like you are compiling test.d as shared while 
linking against the static version of the standard library.

If "dmd test.d" is the command being run there probably is an error in 
with the configuration in dmd.conf, the conf file is probably in /etc.

Depending on the desired behavior you'll need to remove the -shared flag 
from the configuration or add -defaultlib=:libphobos2.so

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list