How to develop a library in D

d, dmd, windows

Solution

The generally accepted way is to use dub, a package manager for D.

There is a good collection of dub packages available already: http://code.dlang.org/

Another way would be to simply publish your package as a git repository, then use it as a git submodule. This is the approach I've been using for my libraries.

Problem

How would you develop a library in D language? I want to write a simple library for image processing that I then want to use in an application. I am looking for analogy to either Java's JARs with Maven system (build, install, use in other projects) or any other package management tool. What I'd like to know is - how to setup a project (two actually, the lib and the app - they are 2 totaly separate projects) - how to build, install, share the library - are there any rules of thumb, particular visibility of symbols, namespacing conventions etc. I'm asking this because I don't have the intuition I do in Java or C++. - In Java you compile a lib to a JAR and you're good to go. Send it, share it, then just include on claspath and you can reuse it. - In C++ you compile it and provide a header file. (or compile it and link to it dynamically) So what's the story with D? I am using Visual-D to develop the code, but I have DUB installed as well.

Original source