www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Using std.net.curl on Ubuntu 12.04 32bit - linker errors

reply "hllnll" <hellnail t-online.de> writes:
My problem seems to be the same as the one that popped up here
(http://stackoverflow.com/questions/10095150/std-net-curl-linker-errors-in-linux)
2 and half years ago. I have to link manually in order to use
std.net.curl. I mainly posting here to ask whether there is a
solution for this in sight or something. Not that it would be a
major problem - one additional line in the makefile - but it
feels bad nevertheless.

Just for demonstration:

import std.string;
import std.stdio;
import std.net.curl;

void main() {
	string html = cast(string)get("http://www.dlang.org");
	writeln(html);
}

dmd main.d -c -o main
gcc main.o -o main -m32 -Xlinker -L/usr/lib -Xlinker -L/usr/lib64
-Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic
-lphobos2 -lpthread -lm -lrt -lcurl

works, whereas

dmd main.d

creates a whole bunch of errors like

"/usr/lib/i386-linux-gnu/libphobos2.a(curl.o): In function
`_D3std3net4curl4Curl19_sharedStaticCtor28FZv':
std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor28FZv+0x6):
undefined reference to `curl_global_init'"

So yeah, is there something done regarding this long known error,
should I post a bugreport somewhere or anything?

regards.
Oct 20 2012
parent Jordi Sayol <g.sayol yahoo.es> writes:
Al 20/10/12 13:15, En/na hllnll ha escrit:
 My problem seems to be the same as the one that popped up here
 (http://stackoverflow.com/questions/10095150/std-net-curl-linker-errors-in-linux)
 2 and half years ago. I have to link manually in order to use
 std.net.curl. I mainly posting here to ask whether there is a
 solution for this in sight or something. Not that it would be a
 major problem - one additional line in the makefile - but it
 feels bad nevertheless.
 
 Just for demonstration:
 
 import std.string;
 import std.stdio;
 import std.net.curl;
 
 void main() {
     string html = cast(string)get("http://www.dlang.org");
     writeln(html);
 }
 
 dmd main.d -c -o main
 gcc main.o -o main -m32 -Xlinker -L/usr/lib -Xlinker -L/usr/lib64
 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic
 -lphobos2 -lpthread -lm -lrt -lcurl
 
 works, whereas
 
 dmd main.d
 
 creates a whole bunch of errors like
 
 "/usr/lib/i386-linux-gnu/libphobos2.a(curl.o): In function
 `_D3std3net4curl4Curl19_sharedStaticCtor28FZv':
 std/net/curl.d:(.text._D3std3net4curl4Curl19_sharedStaticCtor28FZv+0x6):
 undefined reference to `curl_global_init'"
 
 So yeah, is there something done regarding this long known error,
 should I post a bugreport somewhere or anything?
 
 regards.
 
$ dmd -L-lphobos2 -L-lcurl main.d BTW, How to tell dmd to pass a linker flag at the end? Regards, -- Jordi Sayol
Oct 20 2012