RejectedSoftware Forums

Sign up

Binary works when compiled with DMD but not Dub

Hi!

I'm pretty new to D and dub but very much enjoying it so far.

However, I have stumbled across a very confusing issue.

Compiling this code directly with dmd works beautifully, and I have no issues running the binary.

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

void main()
{
	auto content = get("https://httpbin.org/get");
	writefln(content);
}

However,
running dub init curltest and putting that code in app.d
and then running dub run or dub build (--compiler dmd) results in :

std.net.curl.CurlException@std/net/curl.d(4364): Couldn't resolve host name on handle 560A092C2850

This makes it seem like dub (somehow) uses its own libaries or maybe needs configuration to allow curl?

If someone could enlighten me and/or point me in the right direction I'd be very grateful.

Re: Binary works when compiled with DMD but not Dub

Quick correction: If I do dub build and then manually run the binary it works fine too.

So, the issue is the dub run command.

Re: Binary works when compiled with DMD but not Dub

On Wed, 19 Jun 2019 11:01:53 GMT, Ole Erik Brennhagen wrote:

Quick correction: If I do dub build and then manually run the binary it works fine too.

So, the issue is the dub run command.

I tried it exactly same as yours, it worked ok for me.

0:% dub clean
Cleaning package at /home/billy/usr/D/forum...
0:> find .
.
./source
./source/app.d
./forum
./.dub
./.gitignore
./dub.json
./list
0:% cat ./source/app.d
import std.stdio;
import std.net.curl;

void main()
{

  auto content = get("https://httpbin.org/get");
  writefln(content);

}
0:% dub run
Performing "debug" build using /usr/bin/dmd for x86_64.
forum ~master: building configuration "application"...
Linking...
Running ./forum
{
"args": {},
"headers": {
"Accept": "/",
"Host": "httpbin.org",
"User-Agent": "Phobos-std.net.curl/2.089 (libcurl/7.58.0)"
},
"origin": "62.189.181.17, 62.189.181.17",
"url": "https://httpbin.org/get"
}

0:% exit

Script done on 2019-11-20 10:23:54+0000