Using D static library from C

George Sapkin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 5 19:17:49 PDT 2014


On Friday, 6 June 2014 at 02:13:08 UTC, Ellery Newcomer wrote:
> On Thursday, 5 June 2014 at 18:51:25 UTC, George Sapkin wrote:
>> I'm trying to link a simple D static library to C code, but 
>> I'm can't figure out how to do it properly without getting a 
>> segfault when running it.
>
> try this:
>
> dmd -lib test.d -defaultlib=libphobos2.a -oflibtest.a
> gcc main.c libtest.a -l:libphobos2.a -lpthread -lm -lrt

Awesome! That works! Thanks.
So is dmd linking to shared/different phobos2 by default or 
something?


More information about the Digitalmars-d-learn mailing list