On Tuesday, 20 September 2016 at 19:45:57 UTC, Karabuta wrote:
On Tuesday, 20 September 2016 at 15:38:55 UTC, Darren wrote:
On Tuesday, 20 September 2016 at 15:07:53 UTC, rikki cattermole wrote:

Ok lets start at the very beginning...

I think I need to start before that, haha.

I might need more of a step-by-step guide. I'm a complete beginner to programming, not just D. I worked through Programming in D, where I was just compiling with dmd, then when I decided to learn OpenGL I seem to be using dub for everything.

There have been a few libraries I've wanted to use but couldn't because they didn't have a pre-compiled binary, which is all I've been able to get working through sheer trial and error. Some sites say to use things like CMake and cygwin, but I'm uncomfortable using things I have no idea about.

Dub is like a package manager for D (like what npm is to node.js). All dub libraries are hosted at code.dlang.org. When you see a library at code.dlang.org you want to use, you could either type "dub install packagename" whilst in the dub project ROOT or specify dependencies in the dub.json file. You can then run "dub run" which will take care of fetching and building dependencies/libraries from code.dlang.org (including linking and running the binary).

For example, there is a web framework called vibe.d. If I want to use vide.d, I can specify dependencies as;

dependencies: {
    "vide-d":"^0.7.29"
}


In my app.d file (which is available for any dub project created using "dub init projectname") I can import vibe.d using;

import vide.d;
void main() {
...
}

I can now compile and run the program with "dub run" or "dub build" to only build and link without running.

Thank you! This does seem to work for packages listed on the dub page (tested it with gl3n).

Would you be able to tell me how to install libraries that aren't written in D? A lot of what I need to use are written in C/C++, and I've use dub for bindings to those binaries. But what if I need to compile/build those libraries from scratch, or use/link a static library?

I'm not sure if there's a simple answer to this question but I could do with guidance with how to use those libraries with D (other tutorials just focus on C++ with Visual Studio, etc).

Reply via email to