State of interfacing with c++
Johan Engelen via Digitalmars-d
digitalmars-d at puremagic.com
Sat Mar 19 07:32:32 PDT 2016
On Saturday, 19 March 2016 at 10:52:35 UTC, Johan Engelen wrote:
> On Saturday, 19 March 2016 at 08:10:41 UTC, Johan Engelen wrote:
>> On Friday, 18 March 2016 at 20:47:41 UTC, Walter Bright wrote:
>>> On 3/18/2016 6:59 AM, Johan Engelen wrote:
>>>> It'd be nice to be able to call `dmd -ldflags` whose output
>>>> would be the
>>>> standard linker flags.
>>>
>>> dmd -v file.d
>>>
>>> will tell you what command is sent to the linker.
>>
>> That linker command does not include the path to phobos.
>> You would have to parse the output, etc...
>
> Would you accept a PR that adds `dmd -ldflags` ?
>
> For C++/D linking, I used the C++ linker for LDC (master), but
> now I am changing it to using the D compiler with "-L-lstdc++"
> to link. It solves the issue of finding the location of
> phobos/druntime (different for dmd and ldc) and other required
> libs for D code. It also solves a Windows-specific linking
> problem when main() is in C++ code [1].
Unfortunately, this was not true. If your D code does not have
main(), linking does no work with DMD on Windows: phobos is not
linked when there is no main(). Note that "phobos" also contains
druntime and so a D source file with only "void foo() {}" does
not link, and results in unresolved external symbol _d_assert
among others.
This is giving me a major headache at the moment while trying to
change LDC's build.
(on Linux and Mac, it turns out things are easier)
More information about the Digitalmars-d
mailing list