On Wednesday, 23 November 2016 at 19:49:35 UTC, Rubikoid wrote:
For example, i have test.cpp:
#include <stdio.h>
void test()
{
   printf("test\n");
}
And test.d:
import std.stdio;
extern (C++) void test();
void main()
{
    test();
    readln();
}
How i should compile test.cpp using g++ to link it normally?

* Under linux:
  - create the object
    g++ -c test.cpp
  - link:
    dmd test.d test.o

* Under windows 32 bit:
 - create the object:
Use digital mars C/C++ (dmc) to create an OMF object (GCC would produce COFF) then
 - link:
    dmd test.d test.obj

Note that in both cases it can be better not to use the same name for the cpp object. With more C++ objects you could create an archive (aka static library) but for just one source this is useless.

Reply via email to