D Tutorial / Starting With D / Compiler /
DMD
This page is here to instruct you in the installation and use of the Digital Mars D compiler (DMD). There is more than one way to install programs, the simplest is the universal method.
|
Installation
Universal Install
This method works across all platforms with only slit differences because of how the
PATH is handle across platforms.
- Download the zip file and extract it to your location of choice.
- You're done. You can now compile programs from the terminal.
Windows dmd.bat:
Linux dmd.sh:
|
Windows
Follow the Universal directions above. Then to set the path:
- On Windows 2000 and newer, use the System or My Computer Properties/Advanced tab/Environment Variables button, and add the paths to the end of the system path for allusers. Separate paths using a semicolon.
- The added path should look something like: C:/dmd/windows/bin
- (See the tech tip "
Running DMD From The Command Prompt" for more information.)
Linux
System Install
You can use the DEB/RPM packages or follow these manual instructions.
|
- Download and unzip, like above (you can do this from any directory)
- Install the linux executables to /usr/local/bin (and make them executable too)

install -p -m 0755 dmd/linux/bin/dmd dmd/linux/bin/obj2asm dmd/linux/bin/dumpobj /usr/local/bin
- Install the manpages to /usr/local/man (under the man1 subdirectory)

install -p -m 0644 dmd/man/man1/dmd.1 dmd/man/man1/obj2asm.1 dmd/man/man1/dumpobj.1 /usr/local/man/man1
- Install the library to /usr/local/lib:

install -p -m 0644 dmd/lib/libphobos.a /usr/local/lib
- You can install all the Phobos import modules to a directory like /usr/local/src/phobos

mkdir -p /usr/local/src/phobos (cd dmd/src/phobos; find -name '*.d' | xargs tar c) | (cd /usr/local/src/phobos; tar xv)
[Environment]DFLAGS=-I/usr/local/src/phobos -L-L/usr/local/lib
Using Bash Script
You can also choose to use a
bash script created to handle installation and updating of DMD.
- install-d
- Install DMD
- install-tango
- Install Tango, expects DMD to have been installed with install-d
- dmd-switch
- If you have installed two of the following DMD 1.x, 2.x, or Tango with the above scripts, this allows you to choose what will be used when calling $ dmd
AMD64
Since DMD is not yet 64bit after you do the installation you will need a few more packages. The packages are similar on all distributions, below are some distro specific instructions:
Ubuntu
|
Also you may need the 32bit libraries to run your compiled program.
|
Arch Linux
If you have gcc-multilib installed, you should remove it before starting:
|
You can then use:
|
To install cross32-gcc from AUR. See
http://wiki.archlinux.org/index.php/Yaourt for how to install yaourt. You should now edit your dmd.conf and make sure it uses the 32bit gcc for linking, by adding the following in the [Environment] section:
|
Your dmd.conf should now look something like:
|
Mac OS X
Compiling Programs
Compiling just requires calling dmd and listing your source files. As a project grows this can be troublesome so there have been many build tools created to automate this.
Windows:
|
Linux/Mac OS X:
|
If it worked the result is cryptic, but pretty boring.
Output on Windows:
|
Output on Linux:
|
Output on Mac OS X: (i.e. nothing at all, nice and quiet)
Related
- D Compilers
- Learning D as a first language
- Learning D as a second language
- Language Specification
- Development with D