Archive

Archive for the ‘Programming Language’ Category

Install D (GDC+Tango) on Ubuntu

September 5th, 2009 nawaman 2 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