linking external libs

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 2 05:19:06 PDT 2015


On 7/2/15 8:10 AM, Nicholas Wilson wrote:
> So test.d depends on libgmp.a
>
> Unsurprisingly:
> $dmd test.d
>   fails to find libgmp.a
>
> So tell it  to look
> $dmd  -L-lgmp test.d
>
> finds the wrong one or doesn't find it.
>
> Tell it where to look
>
> $dmd -L-L/usr/local/lib -L-lgmp test.d
>
> Ok. Now it fails to find Phobos. Ok
>
> $dmd -L-L/usr/local/lib -L-L/usr/share/dmd/lib -L-lgmp -L-lphobos2 test.d
>
> .... still fails to find Phobos. WTF? is there a way out of this
> revolving door?
>
> reordering the linker flags doesn't seem to help.
>
> Also is there a binding to GMP somewhere? I just hacked one together.

Try dmd -v, it will tell you the link line. Then you can try it yourself 
to see how to get it to work. I know dmd has problems with link line 
parameters, because it always puts Phobos somewhere. But this is 
generally for libraries that Phobos needs, not user code.

A full example may be useful too.

-Steve



More information about the Digitalmars-d-learn mailing list