digitalmars.D.learn - linking external libs
- Nicholas Wilson (18/18) Jul 02 2015 So test.d depends on libgmp.a
- Steven Schveighoffer (7/22) Jul 02 2015 Try dmd -v, it will tell you the link line. Then you can try it yourself...
- Nicholas Wilson (6/15) Jul 02 2015 linker command is
- FreeSlave (4/22) Jul 02 2015 Are you on OSX? (I consider it from /Users instead of /home) Try
- Steven Schveighoffer (6/21) Jul 02 2015 OK, but what I meant was, run this line yourself and see if you can get
- qznc (6/8) Aug 29 2015 I could need the bindings to fix the pidigits benchmark.
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. -Nic
Jul 02 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
Jul 02 2015
On Thursday, 2 July 2015 at 12:19:06 UTC, Steven Schveighoffer wrote:On 7/2/15 8:10 AM, Nicholas Wilson wrote:linker command is gcc test2.o -o test -m64 -L/usr/share/dmd/lib -L/usr/local/lib -lgmp -lphobos2 -L/Users/nicholaswilson/d/lib/ -lphobos2 -lpthread -lm[...]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
Jul 02 2015
On Thursday, 2 July 2015 at 12:47:52 UTC, Nicholas Wilson wrote:On Thursday, 2 July 2015 at 12:19:06 UTC, Steven Schveighoffer wrote:Are you on OSX? (I consider it from /Users instead of /home) Try export LIBRARY_PATH=/usr/local/lib. Can you build C application linked to libgmp this way?On 7/2/15 8:10 AM, Nicholas Wilson wrote:linker command is gcc test2.o -o test -m64 -L/usr/share/dmd/lib -L/usr/local/lib -lgmp -lphobos2 -L/Users/nicholaswilson/d/lib/ -lphobos2 -lpthread -lm[...]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
Jul 02 2015
On 7/2/15 8:47 AM, Nicholas Wilson wrote:On Thursday, 2 July 2015 at 12:19:06 UTC, Steven Schveighoffer wrote:OK, but what I meant was, run this line yourself and see if you can get it to link by tweaking things :) D isn't doing anything magic here. And without full code/environment, it's impossible to tell you why this doesn't work. -SteveOn 7/2/15 8:10 AM, Nicholas Wilson wrote:linker command is gcc test2.o -o test -m64 -L/usr/share/dmd/lib -L/usr/local/lib -lgmp -lphobos2 -L/Users/nicholaswilson/d/lib/ -lphobos2 -lpthread -lm[...]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
Jul 02 2015
On Thursday, 2 July 2015 at 12:10:52 UTC, Nicholas Wilson wrote:Also is there a binding to GMP somewhere? I just hacked one together.I could need the bindings to fix the pidigits benchmark. There is this 7y old code on dsource: http://www.dsource.org/projects/bindings/browser/trunk/gmp The readme says "This is in alpha state. All functions that have been tried seem to work. (8 out of many)", so not that confident.
Aug 29 2015