digitalmars.D.learn - Link errors with curl, libevent, OpenSSL
- Vladimir Panteleev (45/45) Jan 24 2015 On my Ubuntu Server, I can't link any D program which uses
- AndyC (7/53) Jan 25 2015 What weirdness has Ubuntu done that this doesn't work? I'm
- AndyC (4/30) Jan 25 2015 Yep, Ubuntu bug:
- Vladimir Panteleev (5/39) Jan 25 2015 Thank you. It looks like this is an incompatibility between DMD
On my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example: ////////////////////////////// import std.net.curl; import std.stdio; void main() { writeln(get("dlang.org")); } ////////////////////////////// dlang k3:~/2015-01-25$ dmd -L-lcurl test.d /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4HTTP19_sharedStaticCtor34FZv': /usr/local/src/phobos/std/net/curl.d:2503: undefined reference to `curl_version_info' /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4Curl19_sharedStaticCtor35FZv': /usr/local/src/phobos/std/net/curl.d:3497: undefined reference to `curl_global_init' /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4Curl19_sharedStaticDtor36FZv': /usr/local/src/phobos/std/net/curl.d:3503: undefined reference to `curl_global_cleanup' [...] collect2: error: ld returned 1 exit status --- errorlevel 1 The library (.a and .so) is installed and DMD passes -lcurl to gcc. This is what DMD runs: gcc test.o -o test -m64 -lcurl -L/usr/local/lib/x86_64-linux-gnu -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt I got the above program to build by editing /etc/dmd.conf and adding -L-l:libphobos2.a -L-lcurl to DFLAGS. However, this doesn't help when linking with other D libraries, e.g. when using Dub. I believe this problem is documented here: https://issues.dlang.org/show_bug.cgi?id=7044 https://issues.dlang.org/show_bug.cgi?id=12572 I don't see a workaround that would apply to dub, though. Is there a fix or workaround? I think this can be fixed in Dub to make it pass the libraries in the correct order, but I don't normally use Dub so I'm not sure. I sort of need this to be able to work on dlang.org - some functionality is only provided by posix.mak, which doesn't work under Cygwin.
Jan 24 2015
On Sunday, 25 January 2015 at 05:48:26 UTC, Vladimir Panteleev wrote:On my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example: ////////////////////////////// import std.net.curl; import std.stdio; void main() { writeln(get("dlang.org")); } ////////////////////////////// dlang k3:~/2015-01-25$ dmd -L-lcurl test.d /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4HTTP19_sharedStaticCtor34FZv': /usr/local/src/phobos/std/net/curl.d:2503: undefined reference to `curl_version_info' /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4Curl19_sharedStaticCtor35FZv': /usr/local/src/phobos/std/net/curl.d:3497: undefined reference to `curl_global_init' /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4Curl19_sharedStaticDtor36FZv': /usr/local/src/phobos/std/net/curl.d:3503: undefined reference to `curl_global_cleanup' [...] collect2: error: ld returned 1 exit status --- errorlevel 1 The library (.a and .so) is installed and DMD passes -lcurl to gcc. This is what DMD runs: gcc test.o -o test -m64 -lcurl -L/usr/local/lib/x86_64-linux-gnu -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt I got the above program to build by editing /etc/dmd.conf and adding -L-l:libphobos2.a -L-lcurl to DFLAGS. However, this doesn't help when linking with other D libraries, e.g. when using Dub. I believe this problem is documented here: https://issues.dlang.org/show_bug.cgi?id=7044 https://issues.dlang.org/show_bug.cgi?id=12572 I don't see a workaround that would apply to dub, though. Is there a fix or workaround? I think this can be fixed in Dub to make it pass the libraries in the correct order, but I don't normally use Dub so I'm not sure. I sort of need this to be able to work on dlang.org - some functionality is only provided by posix.mak, which doesn't work under Cygwin.What weirdness has Ubuntu done that this doesn't work? I'm running Slackware and just tried your example and it works fine. Does Ubuntu have developer curl packages as well as regular curl packages? Maybe libcurl-dev package? -Andy
Jan 25 2015
On Sunday, 25 January 2015 at 15:11:33 UTC, AndyC wrote:On Sunday, 25 January 2015 at 05:48:26 UTC, Vladimir Panteleev wrote:Yep, Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1001576 -AndyOn my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example: ////////////////////////////// import std.net.curl; import std.stdio; void main() { writeln(get("dlang.org")); } ////////////////////////////// dlang k3:~/2015-01-25$ dmd -L-lcurl test.d /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4HTTP19_sharedStaticCtor34FZv': /usr/local/src/phobos/std/net/curl.d:2503: undefined referenceWhat weirdness has Ubuntu done that this doesn't work? I'm running Slackware and just tried your example and it works fine. Does Ubuntu have developer curl packages as well as regular curl packages? Maybe libcurl-dev package? -Andy
Jan 25 2015
On Sunday, 25 January 2015 at 15:23:03 UTC, AndyC wrote:On Sunday, 25 January 2015 at 15:11:33 UTC, AndyC wrote:Thank you. It looks like this is an incompatibility between DMD and Ubuntu enabling --as-needed. This pointed me in the right direction to find a workaround: https://issues.dlang.org/show_bug.cgi?id=12572#c5On Sunday, 25 January 2015 at 05:48:26 UTC, Vladimir Panteleev wrote:Yep, Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/curl/+bug/1001576On my Ubuntu Server, I can't link any D program which uses libraries other than Phobos. Example: ////////////////////////////// import std.net.curl; import std.stdio; void main() { writeln(get("dlang.org")); } ////////////////////////////// dlang k3:~/2015-01-25$ dmd -L-lcurl test.d /usr/local/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function `_D3std3net4curl4HTTP19_sharedStaticCtor34FZv': /usr/local/src/phobos/std/net/curl.d:2503: undefined referenceWhat weirdness has Ubuntu done that this doesn't work? I'm running Slackware and just tried your example and it works fine. Does Ubuntu have developer curl packages as well as regular curl packages? Maybe libcurl-dev package? -Andy
Jan 25 2015