Home > Linux Tricks, Programming Language > Install D (GDC+Tango) on Ubuntu

Install D (GDC+Tango) on Ubuntu

September 5th, 2009 nawaman Leave a comment Go to comments

I want to learn a programming language that can be compiled to native code. For some reason C and C++ does not fit me. The language is not a problem but the tool chains and library as well as memory management are the problems.

Here come “D”. D is such language I’ve been looking for. The problem of D is that it is new not much tutorials or instructions can be found. Most of those are also for Windows (where most people are). After many attempts, I finally success. So the following is the instruction to set up programming environment for D on Ubuntu. Later articles, I will show you how to set up working environment for Eclipse and GtkD (GUI library for GTK+). I hope that this should be useful to many people.

Firstly, Install GDC (D compiler) with Tango (one of the two standards libraries) and DSSS (D tool-chain). The instruction works for Ubuntu 7.04 to 9.04.

Follow Alternative 3 in http://prowiki.org/wiki4d/wiki.cgi?HowToUbuntu#Alternative3InstallingtheGDCcompilerwithTangoandDSSS. I duplicate it here with some updates.

1: Install infarstructure package.

sudo aptitude install build-essential

2: Download the latest release.

Go to the following webpage and download the installer that is bundled with both GDC and DSSS: http://www.dsource.org/projects/tango/wiki/GdcDownloads. Choose the “Bundled with both GDC and DSSS: ” (The bottom one) or just download it directly with wget:

wget http://downloads.dsource.org/projects/tango/0.99.8/tango-0.99.8-gdcr249-forDSSS-gdc-i686-pc-linux-gnu-withDSSS-withGDC.sh

3: Then we make the file executable:

chmod +x tango-0.99.8-gdcr249-forDSSS-gdc-i686-pc-linux-gnu-withDSSS-withGDC.sh

4: Execute the script:

sudo ./tango-0.99.8-gdcr249-forDSSS-gdc-i686-pc-linux-gnu-withDSSS-withGDC.sh

You will be asked for an installation directory the recommended is: /usr/local

5: Finally configure rebuild

sudo nano /etc/rebuild

Make it contain these two lines:

include=/usr/local/include/d
flags=-fversion=Posix -fversion=Tango

You are done.

To test, create an example file: hello.d

import tango.io.Stdout;

void main (char[][] args) {

    if (args.length < 2) {
        Stdout ("usage is: hello name [name] ... [name]").newline;
	} else {
       foreach (name; args[1..$])
                Stdout.formatln ("hello {}", name);
    }
}

Then, compile it with:

rebuild something.d

In later articles, I will show you how to setup working environment with Eclipse and how can you install GUI library (GtkD).

Enjoy Coding :D

  1. October 28th, 2009 at 14:24 | #1

    Please keep in mind that you are installing pretty old versions of GDC and Tango, which is pretty crucial because most of the projects around D are still pretty fast-moving. For instance, I stumbled over numerous compiler bugs on my first days with D when I tried it out (this is quite a while ago now). Unfortunately, GDC development has stalled for quite a while (it has just been resurrected though), so you are probably better of using DMD or LDC for now…

    (In case you should need instructions, I recently posted a writeup on how to install them at my blog:
    http://klickverbot.wordpress.com/2009/07/28/installing-dmd-ldc-tango-and-dsss-on-kubuntu-jaunty/)

  2. October 29th, 2009 at 01:31 | #2

    That’s excellent. :D Thanks, I will take a look at it.

  1. No trackbacks yet.