DLang Notes and Examples
← prev | next →     Top-level ToC     /typical-project-structure.html     (printable version)

The quickstart chapter gave an example of running your code from one file like a script. A more customary program setup is to use dub to set up and manage a project.

Dub is the DLang build tool and package manager (more info about dub). If you installed dmd via its .deb package, you’ll already have dub.

$ dub --version
DUB version 1.5.0, built on Oct  9 2017

Try dub -h, or dub <some-command> -h.

Create a project:

cd ~/dev
# dub will create the proj dir for you.
dub init my-proj  # Follow interactive prompts.
cd my-proj        # Take a peek at the .gitignore file.
# edit source/app.d
dub               # Builds and runs your app.

You could also mkdir my-proj, cd into it, and run dub init and get the same result. (See dub init -h for more detailed help.)

Your project configuration file can either be dub.json (the default) or dub.sdl (just use json).

Output from that last dub command will be a short “hello world” message as you can see from the contents of source/app.d.

Note: if you’re got a source/app.d file, then your program is an app. Otherwise it’s a library/module.

A bit of terminology: within D, the term “package” means two things: