On Monday, 24 August 2015 at 06:28:34 UTC, Yazan D wrote:
On Sun, 23 Aug 2015 16:00:16 +0000, Tony wrote:

Thanks for the replies. It compiles OK with just. However, it isn't linking:

/usr/bin/ld: cannot find -lcurl


I do have some versions of libcurl on my system:

/usr/lib/x86_64-linux-gnu/libcurl.so.3 /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0 /usr/lib/x86_64-linux-gnu/libcurl.so.4

I see there is a -L option to pass things to the linker

-Llinkerflag   pass linkerflag to link

but I am not sure how to use it.

I've had the same problem recently. What I did was that I ran `dmd main.d -L-L/usr/lib/x86_64-linux-gnu/ -L-lcurl -v`. It would still fail to link, but I can find the linking command from the verbose output. It was something like this: `gcc main.o -o main -m64 -L/usr/lib/x86_64-linux- gnu/ -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic -
l:libphobos2.a -lpthread -lm -lrt`.
As you can see, -lcurl is there, but it still needs to be added again after -l:libphobos2.a. So just add it again so the command becomes: `gcc main.o -o main -m64 -L/usr/lib/x86_64-linux-gnu/ -lcurl -L/usr/lib/ x86_64-linux-gnu -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -
lrt -lcurl`. And it links and runs.

I had an additional -lcurl in already in my output, but added another at the end:

gcc weather_report.o -o weather_report -m64 -L/usr/lib/x86_64-linux-gnu/ -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic -lcurl -l:libphobos2.a -lpthread -lm -lrt -lcurl

but it still complains that it cannot find -lcurl. It even does it if I add -lcurl everywhere:

gcc weather_report.o -o weather_report -m64 -L/usr/lib/x86_64-linux-gnu/ -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic -lcurl -l:libphobos2.a -lcurl -lpthread -lcurl -lm -lrt -lcurl

As an aside, I remember having to add additional mentions of a library in a link line years ago on Unix. I am surprised they haven't changed the way it works so that you only have to mention it once.

Reply via email to