Vous êtes sur la page 1sur 34

Install of Bloodshed Dev-C++: a step by step guide.

Documentation: Ian Cowell.


Two steps are involved in duplicating the lab environment of Dev-C++ in your home computer:
(1) installing Dev-C++
(2) a bit of customization.
Then there some simple exercises for:
(1) Creating a new project
(2) Opening an old project
(3) Using the debug facility
First of all, if you have Cygwin or Bloodshed (DevCpp/Dev++) already installed in your computer,
uninstall them.
Go to the http://www.bloodshed.net/dev/devcpp.html web site and scroll down to:
Downloads
Dev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2
Click on the Download from: SourceForge to start and save the download.
This will save the file devcpp-4.9.9.2_setup.exe

INSTALLING DEV-C++
1. Double Click on the file devcpp-4.9.9.2_setup.exe to start the install

Click OK

I selected English and clicked OK

If you agree with the license then click I Agree

Click Next

Click Install

Click Yes

Click Finish

Click OK

Click Next

Click Next

Click Next

Click OK

Initial Dev-C++ screen


Click Close

CUSTOMISATION.
Setup Compile Options
In the menu select
Tools Compiler Options

Add the following:

You can copy and paste this text:


-g -Wall -Wdeprecated -fpermissive -Wno-sign-compare

-g
Click on Settings

Click on Linker

Click on No for the Generate debugging information entry and select Yes from the drop down
box at the right.

Click Ok
And the configuration is complete.

Create a C++ Project


Click on File -> New Project

Click on the Console Application entry

Click OK

Make sure that the C++ Project is selected


Click OK

We need to change the directory.


Navigate to My Documents (H:\ in the lab)

This assumes that you have selected the directory


C:\Documents and Settings\<your username>\My Documents
Create a directory Projects\Project1 (In the lab H:\ Projects\Project1)

Double click on the new Projects folder

Double click on the new Project1 folder

Click Save
You should have:

Do not worry about the int argc, char *argv[]

In the menu click Execute -> Compile

Click Save
The program compiles

Click Close

In the menu click Execute -> Run

Make sure that the command window is selected (click in the title bar)
And use say the space key.
The command window closes and the program exits.

Select an Existing C++ Project


Start Dev-C++
Select File -> Open Project or File
This will open the last project directory

Double click on the Project1.dev file


(or click on the Project1.dev file and click Open)

Click on the main.cpp

Run the Debugger


Modify the program so that you have:

This is the text:


#include <cstdlib>
#include <iostream>
using namespace std;
//we do not need the parameters
// int argc, char *argv[]
//passed from the calling program
int main()
{
//declare two integer variables
int i;
int j;
//assign values to the variables
i = 0;
j = 3;
//output the values to the window (stdout)
cout << "i= " << i << endl;
cout << "j= " << j << endl;
//tell the system to wait for a response from the keyboard (stdin)
system("PAUSE");
//exit the program and return a success code to the caller
return EXIT_SUCCESS;
}
Compile the program

I clicked on the Compile Log tab to show what was done

Run the program

Press the Enter key.

Click on line 15 (i = 0;) as above (the line number is at bottom left)


Select the menu item Debug -> Toggle Breakpoint

This tells the debug system to stop execution before this line (where the variable i is created)
This breakpoint line is highlighted in red and the breakpoint is the icon red circle with the green
tick. You can toggle the breakpoint on and off by clicking on that icon position.

Select the menu item Debug -> Debug


The program starts but is stopped at the breakpoint.
The Project1.exe window is displayed but nothing is in the window.

Click the Add Watch.

Enter i for the integer variable

and click OK
Do the same for variable j

Notice the values in the Debug tab at the left of the screen.
I=2
J = 35
You may get different values. The values have not been set as yet and so are really undefined.

Click on the Next Step in the Debug pane near the bottom.

The statement i = 0 has been executed and next instruction to be executed is shown by the Blue
highlight. The watch value for i is now 0.
Click on Next Step and the value for j is set.

Click on Next Step. The value of i is printed on the Project.exe window.

Click on Continue. The program runs until the system(PAUSE) is executed.

Click on the Project1.exe window title bar and press the Enter key.

This indicates that the program has finished execution.

Click on the Breakpoint icon (Red Circle with Green Tick) to toggle the breakpoint to off.

Click on Debug

This indicates that the program ran until the system("PAUSE") was executed.
Again click on the Project1.exe window title bar and press the Enter key to let the program finish.
This is the end of the exercise.

Vous aimerez peut-être aussi