Installing DMD, LDC, Tango and DSSS on (K)Ubuntu Jaunty

For quite a while now, I am using the D programming language, version 1 (I have not looked at D2 yet, it is said to be still rather unstable). Even though I like it very much for its syntactical quality and the language itself is reasonably mature, I must admit that setting up the toolchain correctly can still be a very cumbersome task to do, especially when you are new to D.

This post describes an installation routine that should provide you with a working D development environment containing DMD, LDC, Tango and DSSS on (K)Ubuntu Jaunty. Please note that it assumes your system to be »clean« – if you have already installed any D-related software, it is probably advisable to remove it completely to prevent any problems with, for instance, stale files.

mkdir -p ~/tmp
cd ~/tmp

cd dmd/linux/bin/
chmod +x dmd dumpobj obj2asm rdmd
sudo cp dmd dmd.conf dumpobj obj2asm rdmd /usr/local/bin/

cd ~/tmp
svn co tango

cd tango/
sudo DC=dmd build/ —lib-install-dir /usr/local/lib
sudo cp -rf user/object.di user/rt user/std user/tango /usr/local/include/d/

sudo su -c 'echo -e "[Environment]\nDFLAGS=-I/usr/local/include/d -defaultlib=tango-base-dmd -debuglib=tango-base-dmd -L-ltango-user-dmd -version=Tango -version=Posix" > /usr/local/bin/dmd.conf'

sudo su -c 'echo -e "# dsss\ndeb jaunty main" >> /etc/apt/sources.list'
sudo apt-get install dsss
sudo su -c 'echo "profile=dmd-posix-tango" > /etc/drebuild/default'

You should now be able to build your D/Tango programs with DMD and DSSS.

I would suggest giving LDC at least a short glance, a fairly young compiler project which leverages LLVM as its code generating backend. It is maturing very quickly and allows you to make use of the various features the LLVM compiler infrastructure provides, the most noticeable probably being its excellent optimization routines. Fortunately, there are current binary packages available at launchpad, so all that is needed to LDC is:

sudo su -c 'echo -e "# ldc-daily\ndeb karmic main\ndeb karmic main universe" >> /etc/apt/sources.list'
sudo apt-get update

sudo apt-get install ldc-daily libtango-ldc-daily-dev

cd ~/tmp
wget -O ldc-posix-tango
sudo su -c 'sed "s:ldc.rebuild.conf:/etc/ldc/ldc.rebuild.conf:" /etc/drebuild/ldc-posix-tango'

sudo su -c 'echo "profile=ldc-posix-tango" > /etc/drebuild/default'

Note that the above commands install a daily snapshot of LDC, which I would recommend to use due to the currently fast development of LDC. In order not to break you Jaunty installation, please do not forget to comment out the official »karmic« repositories (which contain some dependencies for ldc-daily) in your /etc/apt/sources.list and run apt-get update after the installation is completed.

Both compilers are set up to use Tango, do not install Tango via DSSS! If you want to switch compilers, just activate the corresponding profile in /etc/drebuild/default and do not forget to rebuild any D libraries you might have compiled and installed with the old compiler (just run dsss net install … for the ones you installed using DSSS).

Since I wrote this post, Tango received yet another big structural change to its codebase (amongst other changes, the core and user libraries have been merged). Now, you should use the supplied »bob« tool now to build tango. Additionally, Karmic is now stable so you might have to adapt the APT repository-related instructions.