Using D static library from C

Ellery Newcomer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 5 19:22:44 PDT 2014


On Friday, 6 June 2014 at 02:17:50 UTC, George Sapkin wrote:
> 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?

yeah, -defaultlib=libphobos2.so is the other option, I guess it's 
default now.


More information about the Digitalmars-d-learn mailing list