June 06, 2014 Re: Using D static library from C | ||||
---|---|---|---|---|
| ||||
Posted in reply to George Sapkin | 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
|
June 06, 2014 Re: Using D static library from C | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | 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?
|
June 06, 2014 Re: Using D static library from C | ||||
---|---|---|---|---|
| ||||
Posted in reply to George Sapkin | 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.
|
Copyright © 1999-2021 by the D Language Foundation