Using D static library from C

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


On Friday, 6 June 2014 at 02:01:12 UTC, Mark Isaacson wrote:
> I found that if I told dmd rather than gcc to do the linking 
> that
> everything just magically worked.
>
> In other words:
> gcc -c cstuff.c
> dmd -c dstuff.d
> dmd cstuff.o dstuff.o
>
> I presume that dmd would be similarly smart with static 
> libraries.

Yes, but I need to integrate this with gcc project. To get around 
phobos2 being linked twice and still have a static lib suitable 
for gcc I'm trying this now:

dmd -c test.d
ar r libtest.a test.o
gcc main.c -ltest -L. -lphobos2 -otest

It works with this small test project. I'll try to integrate this 
into bigger project now.


More information about the Digitalmars-d-learn mailing list