Installing DMD

The official DMD Downloads page provides several options for downloading and installing the compiler, including an installer for Windows, platform-specific packages for Linux distributions, a dmg file for OS X, and compressed archives for all supported platforms. Additionally, a command line is provided that can be entered into a Bash shell to fetch an install script.

The sections below list known options for obtaining DMD for each platform, along with any platform specific details that should be taken into consideration.

Contents

Windows

By default, DMD on Windows is distributed as a 32-bit application and is configured to compile 32-bit binaries. It ships with the OPTLINK linker, the same linker used by the Digital Mars C/C++ compiler. This linker consumes object files in the OMF format, making it incompatible with objects produced by linkers in other modern C and C++ compiler packages on Windows, which typically use the MS-COFF format. However, if the Microsoft compiler toolchain is installed, DMD can be configured to make use of it and produce, and link, object files in the MS-COFF format.

The DMD installer

The installer for Windows linked from the download page is by far the easiest way to install DMD on Windows. If Visual Studio is installed, it will automatically detect the installation and modify DMD's configuration file, then offer to install Visual D, the Visual Studio plugin for D. If no VS installation is found, it will offer to install Visual Studio 2013 Community. It also offers the option of installing the D1 compiler and, finally, will ask permission to configure the system path.

Visual Studio is not required to use DMD's default configuration. However, for modern Windows development, it's a practical necessity. The offer to install VS 2013 is intended for compatibility with all supported Windows systems, but it's not recommended on Windows 8 and later. Users should prefer to install the most recent version of Visual Studio for their system (see the section,
'Installing the Microsoft toolchain') before running the DMD installer.

The compressed archive

DMD is also distributed on Windows as an archive compressed with the 7z format. This can be extracted to any directory (C:\D is the default path used by the installer), which can then be manually added to the system path. If MS-COFF support is desired, the DMD configuration file will need to be manually edited to point to the installation of the Microsoft build tools and SDK (see the section, 'Installing the Microsoft toolchain').

Installing the Microsoft toolchain

For any user who does not already have Visual Studio installed, the Community Edition of Visual Studio, since its introduction with the VS 2015 release, is the preferred package for obtaining the Microsoft toolchain. It installs everything DMD needs to produce binaries in the MS-COFF format, including the Windows SDK. Windows 10 users should prefer the 2017 edition, as the installer allows the selection of only the components required, minimizing the download size and installation time:

Prior to the Community Edition, the Visual Studio Express editions were the only Visual Studio distributions that did not require a commercial license. These editions do not ship with the Windows SDK. Anyone installing on Windows 7 and 8 should prefer to install VS 2015 Community. Windows 10 users should prefer VS 2017 Community. When installing on Windows Vista, it is likely easier to allow the DMD installer to install VS 2013 automatically.

An alternative option for those who would prefer not to install Visual Studio is to install both the Microsoft Build Tools and a system-appropriate version of the Windows SDK. When running the DMD installer, it should still detect the Build Tools. If it does not, please report an issue.

When installing DMD via the compressed archive, or when installing the Microsoft tools after DMD, it is necessary to manually edit the DMD configuration file, sc.ini. This can be found in the windows/bin subdirectory of the DMD directory tree (assuming it's installed in C:\D, it would be C:\D\dmd2\windows\bin\sc.ini). Look for the following comment block in the Environment64 section:

; Windows installer replaces the following lines with the actual paths;VCINSTALLDIR=;WindowsSdkDir=;UniversalCRTSdkDir=;UCRTVersion=

This is a default, unconfigured environment. If the installer had previously detected the Visual Studio installation, the variables would be uncommented and assigned values.

Every Visual Studio and MS Build Tools installation adds a number of shortcuts to the Start menu that will open a command prompt with the proper environment variables configured. To configure these values in sc.ini, open one the appropriate 64-bit command prompt from the Start menu (e.g. "Visual Studio 2017 -> x64 Native Tools Command Prompt for VS 2017", or "Visual Studio 2015 -> VS 2015 x64 Native Build Tools Command Prompt"). From that command prompt, execute each of the following commands, then uncomment the corresponding variable in sc.ini and enter the resulting path.

Find the line matching your version of Visual Studio, or the Build Tools, and remove the semi-colon and version number from that line. For example, if you installed the 2015 Build Tools, change the following two lines:

This will allow the generation of 64-bit binaries (via the -m64 command line flag) with the MS toolchain. To enable 32-bit binary generation (via the -m32mscoff command line flag), open the appropriate 32-bit (x86) VS command prompt and repeat these steps for the variables in the Environment32mscoff section of sc.ini.

Debian Linux compatible

If you have distribution that's based on APT package manager, you might use APT Repository.