CSCI 240
Using the Dev C++ Development Environment


The Dev C++ program can be downloaded at:

http://sourceforge.net/projects/orwelldevcpp/

To download, click on the green Download button.

This will take you to another page where the download window should automatically pop up. After the download is finished, double click the file that was just downloaded in order to Run the program that you just downloaded (it could take a little bit for the program to start running, so be patient).

Select the language for your install and click the OK button. After agreeing to the license agreement, determine the type of install that you want to do. The easist install is to select Full. If you don't want the full install, select Custom from the dropdown list and then make sure that:

are checked. If you want some of the other things, you can check those too. Once you have the options selected, click the Next button. Change the destination to where you would like the program to be installed, this could also include a flash drive. Click the Install button.

After the program has installed, click the Finish button.

Running a Program in Dev-C++

The first time that Dev-C++ is run, a few questions will have to be answered. Click Next on the first screen. Select No and then click Next on the second screen. Click on Ok.

  1. Start Dev-C++.

  2. Select Tools/Compiler Options. Click on the General tab in the window that opens.

  3. Make sure that the checkbox next to "Add the following commands when calling the compiler:" is checked.

  4. Add the following to the box that is below the checkbox:

  5. -std=c++14

  6. Click the OK button. The compiler should now be ready for your first program.

  7. To create a new C++ program, go to File/New/Source File. A blank window will open.

  8. Type in your C++ source code, making sure to fill in the Programmer, Section, and Due Date:

  9. /***************************************************************
    CSCI 240         Program 0
    
    Programmer:
    
    Section:
    
    Date Due:
    
    Purpose: Compiler training
    ***************************************************************/
    
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    cout << "hello, world";
    
    return 0;
    }
  10. Save the file. Use File/Save. You will see the pop-up Save File dialog window. You should select the location where you want your program to be saved. It could be your c: hard drive (on your own PC), your network drive (in the labs) or any subdirectory in any of these locations. Be sure you know where you are saving the file so you can find it tomorrow.

  11. Choose a meaningful file name with a .cpp extension. For example, the program above might be named hello.cpp

    Notice that once you have saved the file with a .cpp extension, some of the words in your program are now in color. For example, the bold words are C++ reserved words that have special meanings. Later, you can set special colors for other kinds of items in your program (e.g. strings, comments) using Tools/Options/Edit. Doing this is optional.

  12. Now compile the program. Choose Execute/Compile. You will see a pop-up window and after a few seconds, the Status should read "Done in ___ seconds". If it does not, you have a compile error on the line that is highlighted. You must find and fix all such errors, and re-compile until you get the "Done in ___ seconds" message.

  13. Once you have the "Done in ___ seconds" message, Close the pop-up window.

  14. Now run the program by choosing Execute/Run. Depending on the nature of your program, you may see a prompt for user input (which you provide by typing on the keyboard) or some output displayed on the black screen (DOS window). If you typed the program listed above, you will see "hello, world"

  15. When the last instruction in your program has executed, Dev-C++ will display the message "Process exited with return value 0. Press any key to continue...". When you do this, the DOS window will disappear.

    Note: If this run step causes the error message "Couldn't create process" to show up. Choose Tools/Compiler Options. On the Compile tab, change the Compiler set to configure option to the opposite value (ie. if it's currently, 64-bit, change it to 32-bit). Re-compile the program and try to run it again.

  16. Congratulations. You have created and run your first C++ program.

  17. Sit back and relax for 15 seconds... now let's go on.

    First a couple of notes on what you have just done.

    When you did Execute/Compile and Run, notice that on the Execute menu there are shortcuts shown: F9 for Compile and F10 for Run. You can use these keys as shortcuts for the corresponding mouse selections. (F11 will do both steps)

    When you are working in Dev-C++, you will need to keep track of several windows: we've seen the pop-up window for Compile, and the DOS window, as well as the window for Dev itself and the editing window within Dev where you type and edit your program. All of these work together and you will need to mentally keep track of which ones are open and where they are (recall, for example, that sometimes the DOS window is minimized as a button on the Task Tray). Sometimes one window may be hidden behind another. We assume that you have used Windows enough that you are familiar with the basics of manipulating the various windows. If not, see one of the 240 TA's during office hours for a brief orientation.

  18. Now, just to see what will happen, let's make a couple of mistakes on purpose. Use the delete key to erase the closing " (double quote character) after the word world in your program. Now try to compile it (F9). Notice that the dialog reports several errors. This is common - one mistake may cause several error messages. Your usual response will be to try to fix the first error in your program (which is usually indicated by the first or first few messages) and re-compile. In this case, the first error mentions "missing terminating " character" and a line number (line 7 if you typed in the program as shown) which will usually indicate the location of the error.

  19. Now try deleting the semicolon at the end of the same line. Compile. You see the same error messages even though we know there are now two errors. This often happens: one error "hides" another. Restore the " but leave the ; missing. Recompile. Now you see the message "error: expected ';' before 'return'".

  20. Restore the ; and change the character string to: "\nhello, world" That's a backslash before the n. Compile and run the program. Notice there is now a blank line at the top of the DOS screen. The sequence "\n" makes the cursor on the DOS screen go down one line. (Try it again using a forward slash to see what will happen.)

  21. Misspell the word main. Make it "maain". Compile. A Linker error should show up at the bottome of the screen. Read it. This illustrates that some error messages are not entirely clear.

  22. Fix the program, compile and run it again.

  23. (Almost) finally, before you leave, save the program. You will normally want to make a backup (a separate) copy of your work in case the the original is lost due to equipment failure (it could happen) or some mistake on your part (also could happen).

  24. Choose File/Exit to quit your Dev session and close Dev. You can then do other work on the computer. First, though, pretend you have come back (another day maybe) to continue working your program.

  25. Start Dev again. Use File/Open and locate the file you want to work on (i.e. in this case, the one you just saved in step 13 or 14). Add another line after the first cout line but before the return line:

  26. cout << "\ngoodbye for now..";

    Compile, run, check it, save, and quit.

    That's enough for one day.

  27. The .cpp file is the one that will be submitted for grading on Blackboard.