On Thursday, 16 April 2015 at 09:46:40 UTC, John Colvin wrote:
On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote:
Hi, I've got this project that requires me to link into a C++
backend. It works just fine when using GDC:

gdc *.d [client libraries]

However, this command using DMD does not work:

dmd -L-lstdc++ *.d [client libraries]

I still get errors involving the standard library not being added
like:

/usr/include/c++/4.8/iostream:74: undefine reference to
`std::ios_base::Init::Init()'
(etc.)

What do I need to do to make this work? Thanks.

I don't know why that's happening, but you can explicitly link using gcc (or ld/gold directly) if you need to. E.g.

dmd -c myFile.d
gcc myFile.o -lphobos2

or whatever is necessary on your project/system.

I had wanted to try this too, but I wasn't sure if the linker knew where phobos2 was on my system. I just tried this now for funsies:

dmd -c *.d
g++ main.o [client files] -lphobos2

With or without that -lphobos2 flag, I get errors like these:

main.d(.text._Dmain+0x18e): undefined reference to `D3std5stdio16__T7writeln(TAyaZ7writeFAyaZv'

Reply via email to