Jump to page: 1 2 3
Thread overview
A valid code that won't run?
Apr 24, 2015
cym13
Apr 24, 2015
Marc Schütz
Apr 24, 2015
cym13
Apr 24, 2015
Iain Buclaw
Apr 24, 2015
Meta
Apr 24, 2015
Dicebot
Apr 24, 2015
Dicebot
Apr 24, 2015
Dicebot
Apr 24, 2015
cym13
Apr 24, 2015
Wyatt
Apr 24, 2015
Daniel Kozak
Apr 24, 2015
cym13
Apr 24, 2015
Adam D. Ruppe
Apr 25, 2015
David Eagen
Apr 24, 2015
Adam D. Ruppe
Apr 25, 2015
Iain Buclaw
Apr 27, 2015
Jacob Carlborg
Apr 27, 2015
Jacob Carlborg
Apr 24, 2015
Ali Çehreli
Apr 24, 2015
cym13
Apr 24, 2015
cym13
April 24, 2015
I have here a little snippet that just won't run (many issues in here):

void main(string[] args) {
    import std.stdio, std.net.curl, std.algorithm;

    "http://rosettacode.org/wiki/Web_scraping"
         .byLine
         .filter!(q{ a.canFind("D") })
         .each!writeln;
}

Let's start with ldc:

$ ldc --version
LDC - the LLVM D compiler (0.15.1):
      based on DMD v2.066.1 and LLVM 3.5.1
        Default target: x86_64-unknown-linux-gnu
        Host CPU: corei7
      ...

$ ldc test.d
test.d(11): Error: no property 'each' for type 'FilterResult!(unaryFun, SyncLineInputRange)'

Same with gdc:

$ gdc --version
gdc (GCC) 4.9.2
...

$ gdc test.d
test.d:11: error: no property 'each' for type 'FilterResult!(unaryFun, SyncLineInputRange)'

I don't remember if std.algorithm.each existed in v2.066 but I find it hard to believe that it is that recent an addition to phobos.

Well, let's try DMD:

$ dmd --version
DMD64 D Compiler v2.067
...

$ dmd test.d
/usr/lib/libphobos2.a(curl.o): In function `_D3std3net4curl4HTTP21_sharedStaticCtor1500FZv':
(.text._D3std3net4curl4HTTP21_sharedStaticCtor1500FZv+0xf): undefined reference to `curl_version_info'
/usr/lib/libphobos2.a(curl.o): In function `_D3std3net4curl4Curl21_sharedStaticCtor1502FZv':
(.text._D3std3net4curl4Curl21_sharedStaticCtor1502FZv+0xf): undefined reference to `curl_global_init'
/usr/lib/libphobos2.a(curl.o): In function `_D3std3net4curl4Curl21_sharedStaticDtor1503FZv':
(.text._D3std3net4curl4Curl21_sharedStaticDtor1503FZv+0x5): undefined reference to `curl_global_cleanup'
/usr/lib/libphobos2.a(curl_c4c_192.o): In function `_D3std3net4curl4HTTP4Impl6__dtorMFZv':
(.text._D3std3net4curl4HTTP4Impl6__dtorMFZv+0x19): undefined reference to `curl_slist_free_all'
/usr/lib/libphobos2.a(curl_c6e_ea.o): In function `_D3std3net4curl3FTP4Impl6__dtorMFZv':
(.text._D3std3net4curl3FTP4Impl6__dtorMFZv+0x18): undefined reference to `curl_slist_free_all'
/usr/lib/libphobos2.a(curl_c6e_ea.o): In function `_D3std3net4curl3FTP3dupMFZS3std3net4curl3FTP':
(.text._D3std3net4curl3FTP3dupMFZS3std3net4curl3FTP+0xab): undefined reference to `curl_slist_append'
/usr/lib/libphobos2.a(curl_c6e_ea.o): In function `_D3std3net4curl3FTP13clearCommandsMFZv':
(.text._D3std3net4curl3FTP13clearCommandsMFZv+0x20): undefined reference to `curl_slist_free_all'
/usr/lib/libphobos2.a(curl_c6e_ea.o): In function `_D3std3net4curl3FTP10addCommandMFAxaZv':
(.text._D3std3net4curl3FTP10addCommandMFAxaZv+0x67): undefined reference to `curl_slist_append'
/usr/lib/libphobos2.a(curl_c73_432.o): In function `_D3std3net4curl4Curl10initializeMFZv':
(.text._D3std3net4curl4Curl10initializeMFZv+0x47): undefined reference to `curl_easy_init'
/usr/lib/libphobos2.a(curl_c74_149.o): In function `_D3std3net4curl4Curl3dupMFZS3std3net4curl4Curl':
(.text._D3std3net4curl4Curl3dupMFZS3std3net4curl4Curl+0x2b): undefined reference to `curl_easy_duphandle'
/usr/lib/libphobos2.a(curl_c78_37c.o): In function `_D3std3net4curl4Curl8shutdownMFZv':
(.text._D3std3net4curl4Curl8shutdownMFZv+0x1a): undefined reference to `curl_easy_cleanup'
/usr/lib/libphobos2.a(curl_c7a_14c.o): In function `_D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionAxaZv':
(.text._D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionAxaZv+0x5d): undefined reference to `curl_easy_setopt'
/usr/lib/libphobos2.a(curl_c7b_14c.o): In function `_D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionlZv':
(.text._D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionlZv+0x2e): undefined reference to `curl_easy_setopt'
/usr/lib/libphobos2.a(curl_c7c_14c.o): In function `_D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionPvZv':
(.text._D3std3net4curl4Curl3setMFE3etc1c4curl10CurlOptionPvZv+0x2e): undefined reference to `curl_easy_setopt'
/usr/lib/libphobos2.a(curl_c7d_207.o): In function `_D3std3net4curl4Curl5clearMFE3etc1c4curl10CurlOptionZv':
(.text._D3std3net4curl4Curl5clearMFE3etc1c4curl10CurlOptionZv+0x29): undefined reference to `curl_easy_setopt'
/usr/lib/libphobos2.a(curl_c7e_67c.o): In function `_D3std3net4curl4Curl16clearIfSupportedMFE3etc1c4curl10CurlOptionZv':
(.text._D3std3net4curl4Curl16clearIfSupportedMFE3etc1c4curl10CurlOptionZv+0x29): undefined reference to `curl_easy_setopt'
/usr/lib/libphobos2.a(curl_c7f_2fb.o): In function `_D3std3net4curl4Curl7performMFE3std8typecons41__T4FlagVAyaa12_7468726f774f6e4572726f72Z4FlagZi':
(.text._D3std3net4curl4Curl7performMFE3std8typecons41__T4FlagVAyaa12_7468726f774f6e4572726f72Z4FlagZi+0x22): undefined reference to `curl_easy_perform'
/usr/lib/libphobos2.a(curl_c55_65b.o): In function `_D3std3net4curl4HTTP16addRequestHeaderMFAxaAxaZv':
(.text._D3std3net4curl4HTTP16addRequestHeaderMFAxaAxaZv+0x11b): undefined reference to `curl_slist_append'
/usr/lib/libphobos2.a(curl_c76_4a1.o): In function `_D3std3net4curl4Curl11errorStringMFiZAya':
(.text._D3std3net4curl4Curl11errorStringMFiZAya+0x11): undefined reference to `curl_easy_strerror'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--- errorlevel 1

Linking error.... It may be interesting there to notice that [1] the foreach version works compiles very well with ldc and gdc (ie: it doesn't seem to be related to a library location problem on my side) and [2] even if no network function is used in the code, simply importing std.net.curl makes it impossible to link when using dmd.

Those may be silly little things, but even if I like D a lot I find these little things tiring (booo, go contribute to fix bug etc....).
April 24, 2015
On 4/24/15 1:05 PM, cym13 wrote:

> I don't remember if std.algorithm.each existed in v2.066 but I find it
> hard to believe that it is that recent an addition to phobos.

It is: https://issues.dlang.org/show_bug.cgi?id=12409

>
> Well, let's try DMD:
>
> $ dmd --version
> DMD64 D Compiler v2.067
> ....
>
> $ dmd test.d
> /usr/lib/libphobos2.a(curl.o): In function
> `_D3std3net4curl4HTTP21_sharedStaticCtor1500FZv':
> (.text._D3std3net4curl4HTTP21_sharedStaticCtor1500FZv+0xf): undefined
> reference to `curl_version_info'
> /usr/lib/libphobos2.a(curl.o): In function
> `_D3std3net4curl4Curl21_sharedStaticCtor1502FZv':
> (.text._D3std3net4curl4Curl21_sharedStaticCtor1502FZv+0xf): undefined
> reference to `curl_global_init'

[snip]

This is a sign you don't have libcurl available.

> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)

Why not try this switch? use dmd -v and see why curl is not being included in link.

> Those may be silly little things, but even if I like D a lot I find
> these little things tiring (booo, go contribute to fix bug etc....).

These are easily fixed issues. Most people don't run into them. D is usually pretty good when it comes to being able to run out of the box.

-Steve
April 24, 2015
On Friday, 24 April 2015 at 17:14:53 UTC, Steven Schveighoffer wrote:
> On 4/24/15 1:05 PM, cym13 wrote:
>> $ dmd test.d
>> /usr/lib/libphobos2.a(curl.o): In function
>> `_D3std3net4curl4HTTP21_sharedStaticCtor1500FZv':
>> (.text._D3std3net4curl4HTTP21_sharedStaticCtor1500FZv+0xf): undefined
>> reference to `curl_version_info'
>> /usr/lib/libphobos2.a(curl.o): In function
>> `_D3std3net4curl4Curl21_sharedStaticCtor1502FZv':
>> (.text._D3std3net4curl4Curl21_sharedStaticCtor1502FZv+0xf): undefined
>> reference to `curl_global_init'
>
> [snip]
>
> This is a sign you don't have libcurl available.

You need to link against libcurl explicitly, it doesn't happen automatically:

    dmd -L-lcurl test.d
April 24, 2015
On 4/24/15 1:26 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm@gmx.net>" wrote:
> On Friday, 24 April 2015 at 17:14:53 UTC, Steven Schveighoffer wrote:
>> On 4/24/15 1:05 PM, cym13 wrote:
>>> $ dmd test.d
>>> /usr/lib/libphobos2.a(curl.o): In function
>>> `_D3std3net4curl4HTTP21_sharedStaticCtor1500FZv':
>>> (.text._D3std3net4curl4HTTP21_sharedStaticCtor1500FZv+0xf): undefined
>>> reference to `curl_version_info'
>>> /usr/lib/libphobos2.a(curl.o): In function
>>> `_D3std3net4curl4Curl21_sharedStaticCtor1502FZv':
>>> (.text._D3std3net4curl4Curl21_sharedStaticCtor1502FZv+0xf): undefined
>>> reference to `curl_global_init'
>>
>> [snip]
>>
>> This is a sign you don't have libcurl available.
>
> You need to link against libcurl explicitly, it doesn't happen
> automatically:
>
>      dmd -L-lcurl test.d

Really? I thought it did it automatically if you import std.curl?

That is something that needs fixing...

-Steve
April 24, 2015
On Friday, 24 April 2015 at 17:14:53 UTC, Steven Schveighoffer wrote:
> On 4/24/15 1:05 PM, cym13 wrote:
>
>> I don't remember if std.algorithm.each existed in v2.066 but I find it
>> hard to believe that it is that recent an addition to phobos.
>
> It is: https://issues.dlang.org/show_bug.cgi?id=12409
>

OK. It's always nice to learn something, I didn't see it in the changelog the
first time I checked (on double-check, it is there).
April 24, 2015
On Friday, 24 April 2015 at 17:26:03 UTC, Marc Schütz wrote:
> On Friday, 24 April 2015 at 17:14:53 UTC, Steven Schveighoffer wrote:
>> On 4/24/15 1:05 PM, cym13 wrote:
>>> $ dmd test.d
>>> /usr/lib/libphobos2.a(curl.o): In function
>>> `_D3std3net4curl4HTTP21_sharedStaticCtor1500FZv':
>>> (.text._D3std3net4curl4HTTP21_sharedStaticCtor1500FZv+0xf): undefined
>>> reference to `curl_version_info'
>>> /usr/lib/libphobos2.a(curl.o): In function
>>> `_D3std3net4curl4Curl21_sharedStaticCtor1502FZv':
>>> (.text._D3std3net4curl4Curl21_sharedStaticCtor1502FZv+0xf): undefined
>>> reference to `curl_global_init'
>>
>> [snip]
>>
>> This is a sign you don't have libcurl available.
>
> You need to link against libcurl explicitly, it doesn't happen automatically:
>
>     dmd -L-lcurl test.d

Nice to have a workarround but it would be much nicer if it did like ldc and gdc that linked didn't need explicit linking...
April 24, 2015
On 24 April 2015 at 19:34, cym13 via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On Friday, 24 April 2015 at 17:26:03 UTC, Marc Schütz wrote:
>>
>> On Friday, 24 April 2015 at 17:14:53 UTC, Steven Schveighoffer wrote:
>>>
>>> On 4/24/15 1:05 PM, cym13 wrote:
>>>>
>>>> $ dmd test.d
>>>> /usr/lib/libphobos2.a(curl.o): In function
>>>> `_D3std3net4curl4HTTP21_sharedStaticCtor1500FZv':
>>>> (.text._D3std3net4curl4HTTP21_sharedStaticCtor1500FZv+0xf): undefined
>>>> reference to `curl_version_info'
>>>> /usr/lib/libphobos2.a(curl.o): In function
>>>> `_D3std3net4curl4Curl21_sharedStaticCtor1502FZv':
>>>> (.text._D3std3net4curl4Curl21_sharedStaticCtor1502FZv+0xf): undefined
>>>> reference to `curl_global_init'
>>>
>>>
>>> [snip]
>>>
>>> This is a sign you don't have libcurl available.
>>
>>
>> You need to link against libcurl explicitly, it doesn't happen automatically:
>>
>>     dmd -L-lcurl test.d
>
>
> Nice to have a workarround but it would be much nicer if it did like ldc and gdc that linked didn't need explicit linking...


You need to explicitly link third party libraries.

April 24, 2015
On 4/24/15 1:37 PM, Iain Buclaw via Digitalmars-d wrote:

>
>
> You need to explicitly link third party libraries.
>

You shouldn't need to explicitly link anything that comes out of phobos IMO.

-Steve
April 24, 2015
On Friday, 24 April 2015 at 17:44:32 UTC, Steven Schveighoffer wrote:
> You shouldn't need to explicitly link anything that comes out of phobos IMO.
>
> -Steve

+1, getting pages of linker errors is extremely confusing and intimidating for newcomers to D.
April 24, 2015
On 04/24/2015 10:26 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm@gmx.net>" wrote:

> You need to link against libcurl explicitly, it doesn't happen
> automatically:
>
>      dmd -L-lcurl test.d

Another option is to add it to the source:

pragma(lib, "curl");

Then it finds the library on the system and links with it.

Ali

« First   ‹ Prev
1 2 3