How compile program with curl support?

2013-08-22 Thread ilya-stromberg

I try to compile program with curl support, but I have error:

import std.net.curl;

void main()
{
}

rdmd main.d
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticCtor34FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor34FZv+0xf): 
undefined reference to `curl_global_init'
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticDtor35FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor35FZv+0x5): 
undefined reference to `curl_global_cleanup'


I try to import libcurl.a library, the same problem:
rdmd -L/usr/lib/x86_64-linux-gnu/libcurl.a main.d
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticCtor34FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor34FZv+0xf): 
undefined reference to `curl_global_init'
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticDtor35FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor35FZv+0x5): 
undefined reference to `curl_global_cleanup'


What should I do to get curl support?
OS is Linux Ubuntu 12.10.


Re: How compile program with curl support?

2013-08-22 Thread evilrat

On Thursday, 22 August 2013 at 07:28:52 UTC, ilya-stromberg wrote:

I try to compile program with curl support, but I have error:
...


i rarely use rdmd, so i can only advice to try using dmd directly 
with following flags and see if it works, and if works its a rdmd 
flags problem in your case:


dmd main.d -L-L/path/to/libcurl -L-llibcurlname.a

(note that first -L is dmd flag to pass linker options)


Re: How compile program with curl support?

2013-08-22 Thread Ivan Kazmenko

On Thursday, 22 August 2013 at 07:28:52 UTC, ilya-stromberg wrote:

undefined reference to `curl_global_init'
undefined reference to `curl_global_cleanup'

What should I do to get curl support?
OS is Linux Ubuntu 12.10.


I recently had the same problem on Windows (thread: 
http://forum.dlang.org/thread/wdmqzyqoowrhqfpwd...@forum.dlang.org). 
 It boiled down to the following: the lib file contained 
functions named like "curl_global_init" but the linker searched 
for "_curl_global_init" (starting with underscore).  I don't have 
OSX available, but the OSX file libcurl.a I downloaded contains 
underscored names and your linker searches for non-underscored 
ones, so that may be an inverse problem.  Unless some OS-specific 
linking magic is supposed to take care of that in your case.


On Windows, I changed the way to produce libcurl D bindings from
implib.exe curl.lib libcurl.dll
to
implib.exe /system curl.lib libcurl.dll
and then I link
in order to introduce the underscores.  Clearly I'm not an 
expert, but this may mean you could find a way to [re]produce the 
bindings library on your side as well.


Ivan Kazmenko.


Re: How compile program with curl support?

2013-08-22 Thread Ivan Kazmenko

On Thursday, 22 August 2013 at 10:00:20 UTC, Ivan Kazmenko wrote:

and then I link

Sorry, that should have been:
and then I link just like
dmd myprog.d
having both curl.lib (D bindings to C++ binary, built locally) 
and libcurl.dll (downloaded C++ libcurl binary) findable by the 
linker (in the same directory in my case).


Re: How compile program with curl support?

2013-08-22 Thread David
> What should I do to get curl support?
> OS is Linux Ubuntu 12.10.

Install libcurl-dev
http://packages.ubuntu.com/de/lucid/libcurl-dev

Add "-L-lcurl" to your commandline



Re: How compile program with curl support?

2013-08-22 Thread evilrat

On Thursday, 22 August 2013 at 10:00:20 UTC, Ivan Kazmenko wrote:
On Thursday, 22 August 2013 at 07:28:52 UTC, ilya-stromberg 
wrote:

undefined reference to `curl_global_init'
undefined reference to `curl_global_cleanup'

What should I do to get curl support?
OS is Linux Ubuntu 12.10.


I recently had the same problem on Windows (thread: 
http://forum.dlang.org/thread/wdmqzyqoowrhqfpwd...@forum.dlang.org).
 It boiled down to the following: the lib file contained 
functions named like "curl_global_init" but the linker searched 
for "_curl_global_init"


underscores is a part of Windows name mangling, this means on 
Windows one can find  both C and its own scheme variant(pascal 
scheme?), i don't remember all details(though you can easily find 
it on the internet), but this is explains ur case.


Re: How compile program with curl support?

2013-08-22 Thread ilya-stromberg

On Thursday, 22 August 2013 at 10:24:49 UTC, David wrote:

What should I do to get curl support?
OS is Linux Ubuntu 12.10.


Install libcurl-dev
http://packages.ubuntu.com/de/lucid/libcurl-dev

Add "-L-lcurl" to your commandline


Thanks for help. Correct answer was here:
http://forum.dlang.org/post/mailman.1089.1350735488.5162.digitalmar...@puremagic.com

$ dmd -L-lphobos2 -L-lcurl main.d

As I can see by google, this is common issue. How can we document 
the compilation proses?


Re: How compile program with curl support?

2013-08-22 Thread evilrat

On Thursday, 22 August 2013 at 13:15:39 UTC, ilya-stromberg wrote:

On Thursday, 22 August 2013 at 10:24:49 UTC, David wrote:

What should I do to get curl support?
OS is Linux Ubuntu 12.10.


Install libcurl-dev
http://packages.ubuntu.com/de/lucid/libcurl-dev

Add "-L-lcurl" to your commandline


Thanks for help. Correct answer was here:
http://forum.dlang.org/post/mailman.1089.1350735488.5162.digitalmar...@puremagic.com

$ dmd -L-lphobos2 -L-lcurl main.d

As I can see by google, this is common issue. How can we 
document the compilation proses?


why do u link phobos when compiler do this for you?

btw in fact i've seen somewhere on site/wiki/forums instructions 
"how to build libcurl for D" or something.


Re: How compile program with curl support?

2013-08-22 Thread ilya-stromberg

On Thursday, 22 August 2013 at 13:20:44 UTC, evilrat wrote:

why do u link phobos when compiler do this for you?


Because without it doesn't work:

$ dmd -L-lcurl main.d
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticCtor34FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor34FZv+0xf): 
undefined reference to `curl_global_init'
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticDtor35FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor35FZv+0x5): 
undefined reference to `curl_global_cleanup'


Have you got any ideas why?!


Re: How compile program with curl support?

2013-08-22 Thread evilrat

On Thursday, 22 August 2013 at 13:27:32 UTC, ilya-stromberg wrote:

On Thursday, 22 August 2013 at 13:20:44 UTC, evilrat wrote:

why do u link phobos when compiler do this for you?


Because without it doesn't work:

$ dmd -L-lcurl main.d
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticCtor34FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor34FZv+0xf): 
undefined reference to `curl_global_init'
/usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function 
`_D3std3net4curl4Curl19_sharedStaticDtor35FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor35FZv+0x5): 
undefined reference to `curl_global_cleanup'


Have you got any ideas why?!


none really, especially on linux :(


Re: How compile program with curl support?

2013-08-22 Thread David
Am 22.08.2013 15:27, schrieb ilya-stromberg:
> On Thursday, 22 August 2013 at 13:20:44 UTC, evilrat wrote:
>> why do u link phobos when compiler do this for you?
> 
> Because without it doesn't work:
> 
> $ dmd -L-lcurl main.d
> /usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function
> `_D3std3net4curl4Curl19_sharedStaticCtor34FZv':
> std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor34FZv+0xf):
> undefined reference to `curl_global_init'
> /usr/lib/x86_64-linux-gnu/libphobos2.a(curl.o): In function
> `_D3std3net4curl4Curl19_sharedStaticDtor35FZv':
> std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticDtor35FZv+0x5):
> undefined reference to `curl_global_cleanup'
> 
> Have you got any ideas why?!

Can't reproduce this:

─[dav1d@archbox][/tmp]╼ cat c.d
import std.net.curl;

void main() {}
─[dav1d@archbox][/tmp]╼ dmd c.d
/usr/lib/libphobos2.a(curl.o): In function
`_D3std3net4curl4Curl19_sharedStaticCtor34FZv':
(.text._D3std3net4curl4Curl19_sharedStaticCtor34FZv+0xf): undefined
reference to `curl_global_init'
/usr/lib/libphobos2.a(curl.o): In function
`_D3std3net4curl4Curl19_sharedStaticDtor35FZv':
(.text._D3std3net4curl4Curl19_sharedStaticDtor35FZv+0x5): undefined
reference to `curl_global_cleanup'
collect2: Fehler: ld gab 1 als Ende-Status zurück
--- errorlevel 1
─[dav1d@archbox][/tmp]╼ dmd c.d -L-lcurl
─[dav1d@archbox][/tmp]╼

So I only get these errors when *not* linking against curl.


Re: How compile program with curl support?

2013-08-22 Thread Gary Willoughby

On Thursday, 22 August 2013 at 13:20:44 UTC, evilrat wrote:

why do u link phobos when compiler do this for you?


For some reason the order of linked libs matters especially with 
curl.


Re: How compile program with curl support?

2013-08-22 Thread Jordi Sayol
On 22/08/13 15:20, evilrat wrote:
> On Thursday, 22 August 2013 at 13:15:39 UTC, ilya-stromberg wrote:
>> On Thursday, 22 August 2013 at 10:24:49 UTC, David wrote:
 What should I do to get curl support?
 OS is Linux Ubuntu 12.10.
>>>
>>> Install libcurl-dev
>>> http://packages.ubuntu.com/de/lucid/libcurl-dev
>>>
>>> Add "-L-lcurl" to your commandline
>>
>> Thanks for help. Correct answer was here:
>> http://forum.dlang.org/post/mailman.1089.1350735488.5162.digitalmar...@puremagic.com
>>
>> $ dmd -L-lphobos2 -L-lcurl main.d
>>
>> As I can see by google, this is common issue. How can we document the 
>> compilation proses?
> 
> why do u link phobos when compiler do this for you?

On static linking, the library order cares. "libphobos2" depends on "libcurl", 
so "libphobos2" should be passed to the linker before than "libcurl".

> 
> btw in fact i've seen somewhere on site/wiki/forums instructions "how to 
> build libcurl for D" or something.
> 

-- 
Jordi Sayol


Re: How compile program with curl support?

2013-08-24 Thread ilya-stromberg

On Thursday, 22 August 2013 at 16:28:32 UTC, David wrote:

Can't reproduce this:

─[dav1d@archbox][/tmp]╼ cat c.d
import std.net.curl;

void main() {}
─[dav1d@archbox][/tmp]╼ dmd c.d -L-lcurl
─[dav1d@archbox][/tmp]╼

So I only get these errors when *not* linking against curl.


It looks like regression. Which OS and compiler version do you 
use?

I have Linux Ubuntu 12.10 and DMD 2.063.2.


Re: How compile program with curl support?

2013-08-24 Thread David
Am 24.08.2013 09:56, schrieb ilya-stromberg:
> On Thursday, 22 August 2013 at 16:28:32 UTC, David wrote:
>> Can't reproduce this:
>>
>> ─[dav1d@archbox][/tmp]╼ cat c.d
>> import std.net.curl;
>>
>> void main() {}
>> ─[dav1d@archbox][/tmp]╼ dmd c.d -L-lcurl
>> ─[dav1d@archbox][/tmp]╼
>>
>> So I only get these errors when *not* linking against curl.
> 
> It looks like regression. Which OS and compiler version do you use?
> I have Linux Ubuntu 12.10 and DMD 2.063.2.

Archlinux 64 Bit 2.063.2, and no, this is not a regression, this worked
for every DMD release so far.