Learning D - Installation
|Note:||You may also want to check out the compiler page on Wiki4D for more options and installation instructions.|
Step 1 - Download D's Compiler and Tools
As with any compiled language the first step to installation is to download the compiler and linker tools. For D, go to Digital Mars and download the appropriate packages (both dmc.zip and dmd.zip for Windows users). Unzip these to a directory whose path has no spaces in it (C:\d\ for Windows or ~user/bin/dmd/ for Linux are common). Most of the rest of the page is for windows folks.
Step 2 - Set Your Path Variable
Add the installation folder to your path environmental variable.
The most user friendly way is to go into System from your control panel, under the Advanced tab and click Environmental Variables at the bottom. Scroll down to path and edit it. Add the directory for the compiler with a semicolon preceding it to the end of the variable.
Step 3 - Decide How To Code, IDE or Text Editor
Windows Batch File for Compilation - Use this in a .bat file to open up .d files if you do not have an IDE.
@echo off cd %~p1 if exist "%~n1.def" ( @echo on dmd "c:\d\dmd\lib\ws2_32.lib" "%~n1.def" %1 ) else ( @echo on dmd "c:\d\dmd\lib\ws2_32.lib" %1 ) @echo off echo Would you like to run the program. Will exit without running after 5 seconds. (y/n)? choice /c yn /t 5 /n /d n If not errorlevel == 2 if errorlevel == 1 ( @echo on "%~n1.exe" pause )
Why do this?
- ws2_32.lib is needed for sockets in windows
- automatically picks up a .def file for windows programming without the console
- choice to run or not run the program
- double clicking d files and having them compile is nice