A valid code that won't run?

cym13 via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 10:05:38 PDT 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....).


More information about the Digitalmars-d mailing list