Article

DMD on Ubuntu 14.04

Published on: Sat, Nov 22, 2014 at 7:22 pm EST
Programming Ubuntu

D, a programming language that is considered a superset of C, is a low-level but highly productive language that allows you to develop many types of applications. This includes, but is not limited to console tools and network applications. With D becoming more popular in select programming communities, you may find it beneficial to invest time into learning and using it. This article will show you how to install the D DMD compiler onto Ubuntu 14.04. These steps were only tested on 14.04 - proceed with caution if you are using a different version of Ubuntu.

Update Server

Run the following command to ensure that your server is up to date:

apt-get update
apt-get dist-upgrade

Download and Install Dlang

While there are different versions of D that you can use (LDC, GDC, DMD), we will be downloading and installing DMD.

For 32-bit:

wget http://downloads.dlang.org/releases/2014/dmd_2.066.1-0_i386.deb
dpkg -i dmd_2.066.1-0_i386.deb

For 64-bit:

wget http://downloads.dlang.org/releases/2014/dmd_2.066.1-0_amd64.deb
dpkg -i dmd_2.066.1-0_amd64.deb

After the installation finishes, you may see an error message. If you do, run the following command to complete the installation:

apt-get install -f

This will download any dependencies needed for DMD to operate. Once everything is done, you can proceed to the next step.

Verify Installation

You will want to verify that DMD is fully installed and operational. To do so, you will need to compile a small "Hello World" application. Create a file called test.d and populate it with the following lines of code:

module main;

import std.stdio;

void main(string[] args)
{
    writeln("Hello World!");
}

Once you save the lines of code, run the following to compile it:

dmd test.d

If everything is successful, you will see a test executable file. Type ./test to execute it. The text Hello World! will be printed to your console. You have successfully installed the DMD compiler onto your server.

Want to contribute ?

You could earn up to $300 by adding new articles