Bug 12572 – pragma(lib, "curl") and -Lcurl broken

Status
RESOLVED
Resolution
DUPLICATE
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2014-04-13T11:53:00Z
Last change time
2016-01-18T08:46:51Z
Keywords
link-failure
Assigned to
nobody
Creator
dlang-bugzilla
See also
https://issues.dlang.org/show_bug.cgi?id=15574

Comments

Comment #0 by dlang-bugzilla — 2014-04-13T11:53:28Z
Currently it appears to be impossible to link against libcurl (at least on Ubuntu 13.10 x64) without manually invoking the linker. When adding pragma(lib, "curl") to a program, or by adding -Lcurl to dmd or rdmd's command-line parameter, the program will still fail to link (the linker complains about not being able to find symbols exported by libcurl). Running dmd with -v reveals that it invokes the linker as follows: gcc test.o -o test -m64 -L/etc/../lib -Xlinker --export-dynamic -lcurl -l:libphobos2.a -lpthread -lm -lrt Moving the "-lcurl" parameter to the end, as follows, resolves the linker problems: gcc test.o -o test -m64 -L/etc/../lib -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt -lcurl I'm marking this issue as critical since it makes std.net.curl incompatible with rdmd, and it forces users to switch to a different method of building their programs should they decide to use std.net.curl at some point in development.
Comment #1 by sean — 2014-06-11T20:30:12Z
Yes, this is a huge pain. libcurl is pretty common for D scripts, and not being able to use rdmd for these scripts stinks.
Comment #2 by eco — 2014-06-11T20:34:00Z
I'd probably call this a duplicate of https://issues.dlang.org/show_bug.cgi?id=7044 but I'll let you decide.
Comment #3 by andy — 2015-01-25T15:28:51Z
It works fine for me on Slackware. I think this is an Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1001576 I think they are recommending getting the proper compile flags with: curl-config --cc --cflags and curl-config --libs
Comment #4 by dlang-bugzilla — 2015-01-26T02:29:54Z
(In reply to AndyC from comment #3) > It works fine for me on Slackware. > > I think this is an Ubuntu bug: I think it's just that Slackware doesn't use --as-needed. > https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1001576 > > I think they are recommending getting the proper compile flags with: > > curl-config --cc --cflags > and > curl-config --libs This might fix curl, but doesn't fix the general case - especially when linking D libraries with C libraries with e.g. dub.
Comment #5 by dlang-bugzilla — 2015-01-26T02:32:09Z
> https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1001576 Thanks, this pointed me in the right direction, and I figured out the following system-wide workaround: # echo 'gcc -Wl,--no-as-needed $*' > /usr/local/bin/gcc-dmd # chmod 755 /usr/local/bin/gcc-dmd # echo 'CC=/usr/local/bin/gcc-dmd' >> /etc/dmd.conf
Comment #6 by code — 2015-09-06T03:51:37Z
*** This issue has been marked as a duplicate of issue 7044 ***