What is DevC++
DevC++ is a full-featured integrated development environment (IDE) that uses the MinGW version of C++. An IDE is a program that allows you to edit, compile, and debug your C++ programs without using the command-line. For those of you who prefer to use your own editor, download the command-line version of MinGW instead.
DevC++ comes with everything you need to compile and link both console-mode and GUI programs that will run on Windows 95/98/NT/2K/XP; your programs will not run on Windows 3.1 or on plain DOS machines however. You don't need to download and install anything else.
The rest of this page will walk you through the steps necessary to download, install, and run your C++ programs using DevC++ and the included version of the MinGW C++ compiler.
What is MinGW?
 MinGW ("Minimalistic GNU for Windows") is a command-line C/C++             compiler and utilities, based on the GNU GCC project. It compiles             and links code to be run on Win32 platforms (Win95 through XP).             Unlike some other versions of GCC, MinGW uses the Microsoft runtime             libraries, distributed with the Windows operating system. Since             these runtime libraries are not distributed using GNU's General             Public License (GPL), you do not have to distribute your source             code with your programs unless, of course, you use a GPL             library in your programs.
Step 1: Download DevC++
Click the link below to download DevC++ 5 from SourceForge:http://prdownloads.sourceforge.net/dev-cpp/devcpp4980.exe
When the download dialog (below) appears, click Save,rather than Open:

Save the file in a download or temporary directory on your local machine. (Be sure to remember where you put it!).
             The downloaded file is about 12.5 MB
Step 2: Install DevC++
Using Windows Explorer, locate the file you downloaded, check it's size to make sure that the download didn't stop prematurely, and then double-click it:
Click OK when the                 Welcome dialog appears, as shown here:
Read through the license                 and then click I Agree to install:
             DevC++ is released under the GNU Public License,             (GPL), which allows you to obtain             and modify the source code to the compiler and IDE.             If you do so, then the changes you make must             also be released under the GPL. However, the             programs you create with MinGW don't             normally link with GPL libraries, so you are             free to distribute the programs you write using             DevC++ and MinGW in any way you wish. Select a folder where you would like to install DevC++. It's best if you don't use a folder that contains spaces, (such as "Documents and Settings"). As you can see here, I've created a folder named bin, where I install all of the programs that I use. Click Install once you've selected a folder:

Here's the dialog that is displayed while the files are decompressed and installed


Step 3: Configure the IDE
 The first time you use DevC++ you'll want to             configure it to your use. (You'll need to do             this the first time you use DevC++ in the Computing             Center as well.)
Configure the Environmental Options:
             Change to the Files & Dir tab, and then click the             little button to the right of User's Default Directory             text field. (You can't type directly in the field.)
Configure the Editor Options :


Configure the Compiler Options :

On the Compiler tab, add the following switches when calling the compiler:
             On the Settings tab, choose Code Generation, and             change Enable exception handling to Yes, as shown here:
             While still on the Settings tab, choose Linker and             change Generate debugging information to Yes as shown here:
Step 4 : Compile, Link, and Run
Here are the instructions to edit, compile, link, and run, a simple 3-file C++ project, based on a simple stock program from pages 416-419 in the C++ Primer Plus, 4th Edition.
Create a new project. You'll want to create a new project for every program, simply because it helps you to keep your files straight, and makes your life less confusing:
Choose Empty Project from the New Project dialog. Provide a name, (HW01 in the shot shown here), and click OK:

DevC++ will drop you in the folder you specified when you configured the Environmental Options in Step 3. Unlike Microsoft's Visual Studio, DevC++ doesn't automatically create a new folder for every project. Since you don't want all of your files in the same folder--especially in this class, where you'll create several different versions of the same files--you should Create a New Folder to store your project, as shown here:
Navigate to the new folder, and save the project file (HW01.dev in the screenshot shown here:
Create your source code files. Start by             right-clicking the project in the Project tab, and then             choosing New File as shown here:
             This creates an Untitled file. Click Save, (or press             Control+S), and provide a name, as shown here:
Repeat the project with each file in your project. Once you've created all of the files, you can type in the source code using the editor. The screenshot here shows the three source files in the project, after all of the code has been entered:

Build the Project. DevC++ doesn't have separate Compile and Build settings, like some development environments. When you click the Compile button, (or press Control+F9), all of the C++ files in the project are compiled (if necessary), and the linker creates the executable program:

As your program is being compiled, you'll see a progress dialog showing the individual steps:

At the bottom of the screen, you'll also see a set of tabs that allow you to see the actual commands sent to the MinGW compiler, just as if you typed them from the command line:

Run the Program. To run the program, you can select the Run toolbar button, as shown here, or press Control+F10.

Unfortunately, when you do that, the program opens a Command Prompt window, runs your program, and then immediately closes the window before you can examine the output.
To get the window to "stick around", you can add a command:

Start the program by clicking the Debug toolbar button (shown here), or by pressing F10:

A Command Prompt window will display the output of your program, and then stop on the breakpoint, leaving the command window open like this:

To close the output window, choose the Debug tab at the bottom of the DevC++ IDE, and click on Continue. This will close the console window.


0 comments:
Post a Comment