Meson has support for compiling D programs. A minimal `meson.build` file for D looks like this:
```meson
project('myapp', 'd')
executable('myapp', 'app.d')
```
## Compiling different versions
If you are using the [version()](https://dlang.org/spec/version.html) feature for conditional compilation, you can use it using the `d_module_versions`
It is important to make the D sources install in a subdirectory in the include path, in this case `/usr/include/d/mylib/mylib`.
All D compilers include the `/usr/include/d` directory by default, and if your library would be installed into `/usr/include/d/mylib`, there
is a high chance that, when you compile your project again on a machine where you installed it, the compiler will prefer the old installed include over
the new version in the source tree, leading to very confusing errors.
This is an example of how to use the D library we just built and installed in an application:
Please keep in mind that the library and executable would both need to be built with the exact same D compiler and D compiler version. The D ABI is not
stable across compilers and their versions, and mixing compilers will lead to problems.
DUB is a fully integrated build system for D, but it is also a way to provide dependencies. Adding dependencies from the [D package registry](https://code.dlang.org/) is pretty straight forward.
You can find how to do this in [Dependencies](Dependencies.md#Dub). You can also automatically generate a `dub.json` file as explained in [Dlang](Dlang-module.md#generatedubfile).