Link errors with curl, libevent, OpenSSL
AndyC via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 25 07:11:32 PST 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 at 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
More information about the Digitalmars-d-learn
mailing list