www.digitalmars.com [Home] [News Groups] [Search] [Books] [DMC++ CD] [D]
Last update Feb 24, 2005

Running DMD From The Command Prompt

by Derek Parnell

Do you understand the Windows (DOS) PATH concept? If not, it is one of a few 'environment variables' that you can define for your system. The PATH variable contains a list of folders where Windows will look in to find a program that you need to run.

On Windows XP...

  1. Right-click on the "My Computer" icon and select "Properties" from the popup menu.
  2. Select the "Advanced" tab.
  3. Click on the "Environment Variables" button near the bottom of the window. This will show you two lists of variables - user ones and system ones.
  4. If you can see a "PATH" variable in the user list, click on that then press the "Edit" button. If you cannot see a "PATH" variable in the user list, click on the "New" button.
  5. You will see an editbox for "Variable name". Make sure this is "PATH".
  6. You will see an editbox for "Variable value". If this already has stuff in it, look thru it to see if it mentions where you installed DMD to. I believe in your case it is "C:\D\dmd\dmd\bin".
  7. If it has both "C:\D\dmd\dmd\bin" and "C:\D\dmd\dm\bin" then you are okay and can close these windows now. Otherwise move the cursor to the end of the current list of folders (in the "Variable value" box), and add this ...
    **NOTICE** the semicolon at the beginning of this new entry and the one in between the two paths.
  8. Now press the various "Ok" buttons to save your results.
To test this, start up a new command window. (Press the green "start" button and select "Run...", enter in "cmd" and press "Ok".) Alternatively, select "Command Prompt" from the green "start" menu.

When the prompt comes up, change folders to "C:\" (type in "cd c:\") Now type in "dmd". List show display the dmd usage info. Now type in "link". This should display the OptLink copyright info.

To compile your program, go to the folder your source code is in. For example, if you saved it in "C:\My Projects\D\" you would type in "cd c:\my projects\d"

If you called your program "dtest.d" (you must end it in ".d" btw), type in "dmd dtest"

This will compile and link your test program. To run your program, type in "dtest"