www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.net.curl

reply "tired_eyes" <pastuhov85 gmail.com> writes:
Hi,
I'm trying to compile this trivial example of std.net.curl:

// app.d
import std.stdio;
import std.net.curl;

void main() {
     auto content = get("dlang.org");
}

Hovewer, "dmd app.d" spits a whole bunch of strange error 
messages:

/usr/lib64/libphobos2.a(curl.o): In function 
`_D3std3net4curl4HTTP21_sharedStaticCtor1520FZv':
std/net/curl.d:(.text._D3std3net4curl4HTTP21_sharedStaticCtor1520FZv+0xf):
undefined reference to `curl_version_info'
/usr/lib64/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl21_sharedStaticCtor1522FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl21_sharedStaticCtor1522FZv+0xa):
undefined reference to `curl_global_init'
/usr/lib64/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl21_sharedStaticDtor1523FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl21_sharedStaticDtor1523FZv+0x5):
undefined reference to `curl_global_cleanup'
/usr/lib64/libphobos2.a(curl_1ca7_192.o): In function 
`_D3std3net4curl4HTTP4Impl6__dtorMFZv':
std/net/curl.d:(.text._D3std3net4curl4HTTP4Impl6__dtorMFZv+0x19): 
undefined reference to `curl_slist_free_all'
/usr/lib64/libphobos2.a(curl_1cca_ea.o): In function 
`_D3std3net4curl3FTP4Impl6__dtorMFZv':
std/net/curl.d:(.text._D3std3net4curl3FTP4Impl6__dtorMFZv+0x18): 
undefined reference to `curl_slist_free_all'
/usr/lib64/libphobos2.a(curl_1cca_ea.o): In function 
`_D3std3net4curl3FTP3dupMFZS3std3net4curl3FTP':
std/net/curl.d:(.text._D3std3net4curl3FTP3dupMFZS3std3net4curl3FTP+0xab):
undefined reference to `curl_slist_append'
/usr/lib64/libphobos2.a(curl_1cca_ea.o): In function 
`_D3std3net4curl3FTP13clearCommandsMFZv':
std/net/curl.d:(.text._D3std3net4curl3FTP13clearCommandsMFZv+0x20): undefined
reference to `curl_slist_free_all'
/usr/lib64/libphobos2.a(curl_1cca_ea.o): In function 
`_D3std3net4curl3FTP10addCommandMFAxaZv':
std/net/curl.d:(.text._D3std3net4curl3FTP10addCommandMFAxaZv+0x67): undefined
reference to `curl_slist_append'
/usr/lib64/libphobos2.a(curl_1ccf_432.o): In function 
`_D3std3net4curl4Curl10initializeMFZv':
std/net/curl.d:(.text._D3std3net4curl4Curl10initializeMFZv+0x3d): 
undefined reference to `curl_easy_init'
/usr/lib64/libphobos2.a(curl_1cd0_149.o): In function 
`_D3std3net4curl4Curl3dupMFZS3std3net4curl4Curl':
std/net/curl.d:(.text._D3std3net4curl4Curl3dupMFZS3std3net4curl4Curl+0x25):
undefined reference to `curl_easy_duphandle'
/usr/lib64/libphobos2.a(curl_1cd4_37c.o): In function 
`_D3std3net4curl4Curl8shutdownMFZv':
std/net/curl.d:(.text._D3std3net4curl4Curl8shutdownMFZv+0x1a): 
undefined reference to `curl_easy_cleanup'
/usr/lib64/libphobos2.a(curl_1cd6_14c.o): In function 
`_D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionAxaZv':
std/net/curl.d:(.text._D3std3net4curl4Curl3setMFE3etc1c4curl10Cu
lOptionAxaZv+0x5d): undefined reference to `curl_easy_setopt'
/usr/lib64/libphobos2.a(curl_1cd7_14c.o): In function 
`_D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionlZv':
std/net/curl.d:(.text._D3std3net4curl4Curl3setMFE3etc1c4curl10
urlOptionlZv+0x2e): undefined reference to `curl_easy_setopt'
/usr/lib64/libphobos2.a(curl_1cd8_14c.o): In function 
`_D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionPvZv':
std/net/curl.d:(.text._D3std3net4curl4Curl3setMFE3etc1c4curl10C
rlOptionPvZv+0x2e): undefined reference to `curl_easy_setopt'
/usr/lib64/libphobos2.a(curl_1cd9_207.o): In function 
`_D3std3net4curl4Curl5clearMFE3etc1c4curl10CurlOptionZv':
std/net/curl.d:(.text._D3std3net4curl4Curl5clearMFE3etc1c4curl1
CurlOptionZv+0x28): undefined reference to `curl_easy_setopt'
/usr/lib64/libphobos2.a(curl_1cda_67c.o): In function 
`_D3std3net4curl4Curl16clearIfSupportedMFE3etc1c4curl10CurlOptionZv':
std/net/curl.d:(.text._D3std3net4curl4Curl16clearIfSupportedMFE3etc1c4curl1
CurlOptionZv+0x28): undefined reference to `curl_easy_setopt'
/usr/lib64/libphobos2.a(curl_1cdb_2fb.o): In function 
`_D3std3net4curl4Curl7performMFE3std8typecons41__T4FlagVAyaa12_7468726f774f6e4572726f72Z4FlagZi':
std/net/curl.d:(.text._D3std3net4curl4Curl7performMFE3std8typecons41__T4FlagVAyaa12_7468726f774f6e45727
6f72Z4FlagZi+0x22): undefined reference to `curl_easy_perform'
/usr/lib64/libphobos2.a(curl_1cb0_65b.o): In function 
`_D3std3net4curl4HTTP16addRequestHeaderMFAxaAxaZv':
std/net/curl.d:(.text._D3std3net4curl4HTTP16addRequestHeaderMFAxaAxaZv+0x11b):
undefined reference to `curl_slist_append'
/usr/lib64/libphobos2.a(curl_1cd2_4a1.o): In function 
`_D3std3net4curl4Curl11errorStringMFiZAya':
std/net/curl.d:(.text._D3std3net4curl4Curl11errorStringMFiZAya+0x11): undefined
reference to `curl_easy_strerror'
collect2: error: ld returned 1 exit status
--- errorlevel 1

DMD 2.068.0, openSUSE 13.2 x64
I'm absolutely sure that I have licurl installed. "zypper info 
libcurl4" shows me that it's version is 7.43.0-2.1
Aug 17 2015
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote:
 Hovewer, "dmd app.d" spits a whole bunch of strange error 
 messages:
try "dmd -lcurl app.d" and see if that helps.
Aug 17 2015
next sibling parent reply "tired_eyes" <pastuhov85 gmail.com> writes:
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote:
 On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote:
 Hovewer, "dmd app.d" spits a whole bunch of strange error 
 messages:
try "dmd -lcurl app.d" and see if that helps.
Error: unrecognized switch '-lcurl'
Aug 17 2015
next sibling parent "yawniek" <dlang srtnwz.com> writes:
On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote:
 On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote:
 On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote:
 Hovewer, "dmd app.d" spits a whole bunch of strange error 
 messages:
try "dmd -lcurl app.d" and see if that helps.
Error: unrecognized switch '-lcurl'
do you use dub? if so, did you add "libs": ["curl"] to your dub.json? if that doesn't help, please post the output of curl-config. e.g. curl-config --libs --built-shared --prefix --static-libs
Aug 17 2015
prev sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote:
 Error: unrecognized switch '-lcurl'
ooh I'm sorry, should have been `dmd -L-lcurl yourprogram.d`
Aug 17 2015
parent "tired_eyes" <pastuhov85 gmail.com> writes:
On Monday, 17 August 2015 at 13:26:29 UTC, Adam D. Ruppe wrote:
 On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote:
 Error: unrecognized switch '-lcurl'
ooh I'm sorry, should have been `dmd -L-lcurl yourprogram.d`
Yes, it did the trick.
Aug 17 2015
prev sibling parent reply "anonymous" <a b.cd> writes:
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote:
 On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote:
 Hovewer, "dmd app.d" spits a whole bunch of strange error 
 messages:
try "dmd -lcurl app.d" and see if that helps.
DMD does not accept -lcurl. From dmd --help: -Llinkerflag pass linkerflag to link ergo dmd -L-lcurl app.d on my machine (64Bit linux mint 17.2 with libcurl4-openssl-dev installed) -L-lcurl reduces the number of linker errors but the example still fails. I run dmd -c app.d dmd -L-lcurl app.o -v and figured out that the linker is invoked (on my machine) with gcc a.o -o a -m64 -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt If I change the order of the libraries (move -lcurl to the end), it links. Used commands: dmd -c app.d gcc app.o -o app -m64 -L/usr/lib/x86_64-linux-gnu -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt -lcurl (the later may be different on OpenSUSE (?) - better check with dmd -v ...)
Aug 17 2015
parent "anonymous" <a b.cd> writes:
On Monday, 17 August 2015 at 13:13:48 UTC, anonymous wrote:

 and figured out that the linker is invoked (on my machine) with
  gcc a.o -o a -m64 -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker
correct (I named the example programm a.d instead of app.d): gcc app.o -o app -m64 -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker This issue is already known: https://issues.dlang.org/show_bug.cgi?id=12572 and https://issues.dlang.org/show_bug.cgi?id=7044
Aug 17 2015