On Friday, 27 October 2017 at 17:43:08 UTC, sivakon wrote:
On Friday, 27 October 2017 at 17:21:39 UTC, Joakim wrote:

This should work:

dmd foo.d Sample.o

Just like the C examples from the D blog:

https://dlang.org/blog/2017/10/25/dmd-windows-and-c/

Just used this! Got this error!

sample.o: In function `foo(int, int, int)':
sample.cpp:(.text+0x17): undefined reference to `std::cout'

Sorry, just responded quickly from my tablet, didn't try it out first. There's actually a variant of this sample that is run as a test from the dmd compiler testsuite, so it is checked hundreds of times a day for pending pull requests, on all officially supported platforms by the auto-tester:

https://auto-tester.puremagic.com/pulls.ghtml?projectid=1
https://github.com/dlang/dmd/blob/master/test/runnable/extra-files/cppb.cpp#L41
https://github.com/dlang/dmd/blob/master/test/runnable/cppa.d#L25

Looking at the D script that runs each compiler test, it adds the following flag for all C++ objects:

https://github.com/dlang/dmd/blob/master/test/d_do_test.d#L499

So adding that flag got your example to work for me:

dmd -L-lstdc++ foo.d Sample.o

Reply via email to