Installing and Using Dev-C++ 1. Installing Dev-C++ Orwell Dev-C++ is a professional C++ IDE, but not as big and complex as Visual Studio. It runs only on Windows; both Windows 7 and Windows 8 are supported. Note that Orwell is the successor to the Bloodshed version installed in some of the labs. This is a good choice if you don t plan to major in CS; it s a small download and easier to install. To download Orwell Dev-C++, start here: http://orwelldevcpp.blogspot.com/ Do *not* click the big DOWNLOAD button, that s a scam. Instead, scroll down, and I would recommend you download and install the first version listed as The setup which includes TDM-GCC 4.9.2 can be downloaded here. Run the setup program to install the IDE. part 1: Getting Started with the Dev-C++ Programming Environment The following steps outline how to properly create a C++ project on a Windows computer using Dev-C++. The exact details may be different based on the version of Dev-C++ you have installed, but the basic ideas are the same. These instructions are written for the computers in our labs, SELE 2249 and 2249F. First, open Dev- C++: Start menu, All Programs, Programming, Bloodshed Dev-C++, and select Dev-C++ : This will start the Dev-C++ program. The first step is to create a new project, so File menu, New >> Project: Prof. Joe Hummel Page 1 of 9
At this point, a new dialog window will open to collect the information that Dev-C++ needs to create a project. THIS IS THE MOST IMPORTANT STEP, and WHERE MOST FOLKS GET IT WRONG, so read carefully. First, here s what you should see: You MUST do 2 things. First, as shown below, click on the icon for Console Application to select it. Second, give your project a name use only letters and numbers, no spaces and no special characters are allowed. So how about Testing123, like this: Click the OK button this is step 1 of 2, and so after you click the OK button a second dialog window will open. THIS STEP IS EQUALLY IMPORTANT, so read carefully. Here s what the 2 nd dialog window should look like it s a typical Windows Save As dialog: You are being asked where to save the project / program you are about to write. This is HUGELY IMPORTANT if you aren t careful, you won t be able to find your program when you are done! By default, Dev-C++ will Prof. Joe Hummel Page 2 of 9
save all files in your DOCUMENTS folder, which is perfectly fine. To maintain some sense of organization, what you want to do is create a folder for every project / program you write. In the dialog window, there is a New Folder button as shown below: Click the New Folder button, and create a new folder give the folder the same name as your project, in this case Testing123 : << continued on next page >> Prof. Joe Hummel Page 3 of 9
NEXT, double-click to open this folder and navigate down one level, into the folder you just created: Now, anything you save will end up in your new Testing123 folder. Go ahead and click the SAVE button to save the Dev-C++ project (.dev) file. You have now properly created a Dev-C++ project. After clicking SAVE, Dev-C++ will now create the skeleton of a valid C++ program, and you can start programming. Here s what you should see, though you may see something different based on the version of Dev-C++ you are working with: Ignore the int argc, char *argv[] you see as part of the main( ) function definition. In the lab, Dev-C++ will auto-generate some code for keeping the console window open when you run your program: Prof. Joe Hummel Page 4 of 9
} system("pause"); return EXIT_SUCCESS; Leave this code at the end of main( ); when we run your program, this will cause the system to wait for you to press a key before closing the window, giving you time to see your program s output. [ Note: if you write code in Dev-C++ and then copy-paste this code into ideone.com or codelabs, you will need to *delete* these two lines and replace with return 0; as we normally do in class. ] Immediately save what Dev-C++ has generated by clicking the small Save All toolbar button as shown below: When you click Save All, you ll be asked to save your main.cpp file this file represents your program. It will be saved in your Testing123 folder by default, which is exactly where you want it. So click SAVE : You are now ready to start programming. Prof. Joe Hummel Page 5 of 9
part 2: Programming in Dev-C++ At this point you should be looking at the simple C++ program generated by Dev-C++. The right-most window pane is the editor, go ahead and edit the program, adding using namespace std; as we normally do: Let s write a simple program in C++ Modify the main() function to input 2 real numbers from the keyboard, compute their average, and output the result. Go ahead and write the code When you want to run your program, you perform two steps: (1) compile, and if there are no errors, then (2) run. To compile your program, use the Execute menu, and select Compile as shown below: Error messages will appear in a window pane that appears along the bottom you may also get some warnings about skipping incompatible, you can safely ignore those. Fix any errors and compile again; repeat until all errors are fixed. Prof. Joe Hummel Page 6 of 9
To run your program, use the Execute menu, and select Run a console window should open, looking something like this: Your program is now running and in this case, waiting for input. Enter 2 numbers, and your program should output the average: Excellent! Press ENTER to close the console window, and then exit out of Dev-C++. part 3: Files created by Dev-C++ At this point Dev-C++ should be closed. Open your Documents folder: the quickest way is Start menu, and then select Documents underneath your user name in the menu that open (top-right of menu area): In Documents, you should see your Testing123 folder: Prof. Joe Hummel Page 7 of 9
Open the Testing123 folder to see what Dev-C++ created: Your C++ program is in the file main.cpp this is the MOST IMPORTANT FILE, and represents your intellectual work. If you need to submit your program for grading, submit this file main.cpp file. If you want to take your work with you when you leave the lab, either (a) copy the entire Testing123 folder, or (b) copy the main.cpp file. For example, you can attach main.cpp in an email to yourself, or copy the folder / file to a USB drive. The other important file is the Dev-C++ project file, the one with the.dev extension. When you want to open Dev-C++ and start working on your program, this.dev file is the one you need to open. Unfortunately, you cannot double-click on the file and startup Dev-C++, at least it doesn t work in the labs. Instead, start Dev- C++ via the Windows Start menu, and then when it s open, drop the File menu, and select Open : << continued on next page >> Prof. Joe Hummel Page 8 of 9
Navigate to the Testing123 folder, open, and select the.dev file: Click the OPEN button, and Dev-C++ will re-open your project, load your C++ program file, and you re ready to start programming again. Prof. Joe Hummel Page 9 of 9