www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.net.curl is not working?

reply "mab" <nitramlxl gmail.com> writes:
Why i get the following Error, when i try to compile a simple 
"Hello World" that imports std.net.curl=

The Error:
# dmd hello.d
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticCtor28FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor28FZv+0xf): 
undefined reference to `curl_global_init'
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticDtor29FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor29FZv+0x5): 
undefined reference to `curl_global_cleanup'
collect2: ld returned 1 exit status
--- errorlevel 1

The Code:
import std.stdio;
import std.net.curl;

void main()
{
   writeln("hello world");
}

My Testsystem: Debian
# uname -a
Linux dexplorer 2.6.32-5-amd64 #1 SMP Mon Feb 25 00:26:11 UTC 
2013 x86_64 GNU/Linux

curl is installed by apt-get install curl.

Thanks!
Apr 26 2013
next sibling parent reply qznc <qznc web.de> writes:
Fri, 26 Apr 2013 19:25:16 +0200: mab wrote

 Why i get the following Error, when i try to compile a simple "Hello
 World" that imports std.net.curl=
 
 The Error:
 # dmd hello.d /usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In
 function `_D3std3net4curl4Curl19_sharedStaticCtor28FZv':
 std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor28FZv+0xf):
 undefined reference to `curl_global_init'
 /usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function
 `_D3std3net4curl4Curl19_sharedStaticDtor29FZv':
 std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor29FZv+0x5):
 undefined reference to `curl_global_cleanup'
 collect2: ld returned 1 exit status --- errorlevel 1
 
 The Code:
 import std.stdio;
 import std.net.curl;
 
 void main()
 {
    writeln("hello world");
 }
 
 My Testsystem: Debian # uname -a Linux dexplorer 2.6.32-5-amd64 #1 SMP
 Mon Feb 25 00:26:11 UTC 2013 x86_64 GNU/Linux
 
 curl is installed by apt-get install curl.
 
 Thanks!
You have to link libcurl via argument: dmd hello.d -L-lcurl
Apr 26 2013
parent reply "mab" <nitramlxl gmail.com> writes:
Thank you for answering. But it didnt work.

I get:
#dmd hello.d -L-lcurl
/usr/bin/ld: cannot find -lcurl
collect2: ld returned 1 exit status
--- errorlevel 1

Curl is installed, as also libcurl3.

I forget to mention that i am using "DMD64 D Compiler v2.062".
Is std.net.curl working in this Version? Because it also didnt 
work on my Windows 7 System.
Apr 26 2013
next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 04/26/2013 10:55 AM, mab wrote:

 Thank you for answering. But it didnt work.

 I get:
 #dmd hello.d -L-lcurl
 /usr/bin/ld: cannot find -lcurl
Try providing the directory that the curl library file is in: #dmd hello.d -L-L/wherever/libcurl/is/in -L-lcurl Ali
Apr 26 2013
prev sibling next sibling parent reply Jordi Sayol <g.sayol yahoo.es> writes:
On 26/04/13 19:55, mab wrote:
 Thank you for answering. But it didnt work.
 
 I get:
 #dmd hello.d -L-lcurl
 /usr/bin/ld: cannot find -lcurl
 collect2: ld returned 1 exit status
 --- errorlevel 1
 
 Curl is installed, as also libcurl3.
You need to install the development curl package: $ sudo apt-get install libcurl4-openssl-dev or $ sudo apt-get install libcurl4-gnutls-dev or $ sudo apt-get install libcurl4-nss-dev
 
 I forget to mention that i am using "DMD64 D Compiler v2.062".
 Is std.net.curl working in this Version? Because it also didnt work on my
Windows 7 System.
 
-- Jordi Sayol
Apr 26 2013
parent "mab" <nitramlxl gmail.com> writes:
On Friday, 26 April 2013 at 18:14:04 UTC, Jordi Sayol wrote:
[...]
 You need to install the development curl package:

 $ sudo apt-get install libcurl4-openssl-dev
 or
 $ sudo apt-get install libcurl4-gnutls-dev
 or
 $ sudo apt-get install libcurl4-nss-dev
[...] That´s it. Thank you!
Apr 26 2013
prev sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 26 April 2013 at 17:55:59 UTC, mab wrote:
 Thank you for answering. But it didnt work.

 I get:
 #dmd hello.d -L-lcurl
 /usr/bin/ld: cannot find -lcurl
 collect2: ld returned 1 exit status
 --- errorlevel 1

 Curl is installed, as also libcurl3.

 I forget to mention that i am using "DMD64 D Compiler v2.062".
 Is std.net.curl working in this Version? Because it also didnt 
 work on my Windows 7 System.
Do you know what the libcurl library is actually called on your system? (try "find /usr -name "*curl*.so*" " or "find /usr -name "*curl*.a*" ) if the name you find is e.g. "libcurl3.so" then you'll have to use the linker flag -lcurl3 instead of lcurl p.s. Please don't be offended if you're already fully aware of this, it's just better to make sure the basics are covered first.
Apr 26 2013
prev sibling parent ollie <ollie home.net> writes:
On Fri, 26 Apr 2013 19:25:16 +0200, mab wrote:

 undefined reference to `curl_global_init'
 undefined reference to `curl_global_cleanup'
These functions are defined in libcurl. Make sure you have installed libcurl if it wasn't installed as a dependency for curl.
Apr 26 2013