On Thursday, 3 November 2016 at 05:16:11 UTC, Dlang User wrote:
I am running Debian Testing and I think I have run into the recent fPIC issue. This is the source code for the test project I am using:

import std.stdio;

void main()
{
        writeln("Edit source/app.d to start your project.");
        readln();
}


When I try to compile a project, I get the following errors (truncated for brevity):


/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libphobos2.a(thread_26c_155.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: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
dmd failed with exit code 1.
Exit code 2
Build complete -- 1 error, 0 warnings


I got the same problem, still under Debian. A fix is to use these flags:

dmd -shared -m64 -fPIC -defaultlib=libphobos2.so app.d

You can also use another compiler:

dub --compiler=ldc2

or

rdmd --compiler=ldc2

Note that it is not recommended to use gdc because it is not up to date, use dmd or ldc2.

Also note, that if you use Emacs + Org Mode,

http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-C.html

you will encounter the same problem. A fix is to add the following line in your .emacs file:

(setq org-babel-D-compiler "rdmd --compiler=ldc2")


Vincent

Reply via email to