Difference between revisions of "Running DMD From The Command Prompt"

From D Wiki
Jump to: navigation, search
(migrated from http://digitalmars.com/techtips/command_prompt.html)
m
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
by Derek Parnell
 
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.
+
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...
 
On Windows XP...
  
1. Right-click on the "My Computer" icon and select "Properties" from the popup menu.
+
# Right-click on the "My Computer" icon and select "Properties" from the popup menu.
 
+
# Select the "Advanced" tab.
2. Select the "Advanced" tab.
+
# 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.
 
+
# 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.
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.
+
# You will see an editbox for "Variable name". Make sure this is "'''PATH'''".
 
+
# 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".
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.
+
# 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 ... ";C:\D\dmd\dmd\bin;C:\D\dmd\dm\bin".  '''NOTICE''' the semicolon at the beginning of this new entry and the one in between the two paths.
 
+
# Now press the various "Ok" buttons to save your results.
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 ...
 
";C:\D\dmd\dmd\bin;C:\D\dmd\dm\bin"
 
**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.
 
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.
Line 32: Line 23:
  
 
This will compile and link your test program. To run your program, type in "dtest"
 
This will compile and link your test program. To run your program, type in "dtest"
 +
 +
This article was originally published at http://digitalmars.com/techtips/command_prompt.html
 +
 +
[[Category:HowTo]]

Latest revision as of 10:16, 14 November 2014

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 ... ";C:\D\dmd\dmd\bin;C:\D\dmd\dm\bin". 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"

This article was originally published at http://digitalmars.com/techtips/command_prompt.html