Linking g++ compiled object files
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Nov 24 09:37:51 PST 2016
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.
More information about the Digitalmars-d-learn
mailing list