Install DMD on Ubuntu 22.04

Install DMD on Ubuntu 22.04

DMD is a compiler for the D programming language. D is a high level, general purpose, statically typed language that has syntax similar to C/C++.

This tutorial explains how to install DMD on Ubuntu 22.04.

Install DMD

Get the latest version of DMD and assign it to variable.

D_VERSION=$(wget -qO -

Download Debian package (.deb) of DMD from official page:

wget -qO dmd.deb${D_VERSION}/dmd_${D_VERSION}-0_amd64.deb

Run the following commands to update the package lists and install DMD:

sudo apt update
sudo apt install -y ./dmd.deb

When installation is finished, we can check DMD version:

dmd --version

You can remove .deb package because no longer needed:

rm -rf dmd.deb

Testing DMD

Create a file called main.d:

nano main.d

Populate file with the following lines of code:

import std.stdio;

void main()
    writeln("Hello world");

Use dmd command to compile code:

dmd main.d -of=test

It builds a binary file named test. Now run it:


Uninstall DMD

If you want to completely remove DMD and related dependencies, run the following command:

sudo apt purge --autoremove -y dmd

Leave a Comment

Cancel reply

Your email address will not be published.