huong dan dev-c

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

Upload: vinh-phat-cao

Post on 20-Feb-2016

228 views

Category:

Documents


0 download

DESCRIPTION

devc

TRANSCRIPT

Page 1: huong dan dev-c

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:DownloadsDev-C++ 5.0 beta 9.2 (4.9.9.2) (9.0 MB) with Mingw/GCC 3.4.2Click 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

Page 2: huong dan dev-c

If you agree with the license then click I Agree

Click Next

Page 3: huong dan dev-c

Click Install

Page 4: huong dan dev-c

Click Yes

Click Finish

Page 5: huong dan dev-c

Click OK

Click Next

Page 6: huong dan dev-c

Click Next

Click Next

Page 7: huong dan dev-c

Click OK

Initial Dev-C++ screen

Click Close

Page 8: huong dan dev-c

CUSTOMISATION.

Setup Compile OptionsIn the menu selectTools → Compiler Options

Add the following:

Page 9: huong dan dev-c

You can copy and paste this text:-g -Wall -Wdeprecated -fpermissive -Wno-sign-compare

Page 10: huong dan dev-c

-g

Click on Settings

Click on Linker

Page 11: huong dan dev-c

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

Page 12: huong dan dev-c

Click Ok

And the configuration is complete.

Page 13: huong dan dev-c

Create a C++ Project

Click on File -> New Project

Click on the Console Application entry

Click OK

Make sure that the C++ Project is selectedClick OK

Page 14: huong dan dev-c

We need to change the directory.Navigate to My Documents (H:\ in the lab)

This assumes that you have selected the directoryC:\Documents and Settings\<your username>\My DocumentsCreate a directory Projects\Project1 (In the lab H:\ Projects\Project1)

Page 15: huong dan dev-c

Double click on the new Projects folder

Page 16: huong dan dev-c

Double click on the new Project1 folder

Click Save

You should have:

Page 17: huong dan dev-c

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

Page 18: huong dan dev-c

In the menu click Execute -> Compile

Click Save

The program compiles

Click Close

Page 19: huong dan dev-c

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.

Page 20: huong dan dev-c

Select an Existing C++ Project

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

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

Page 21: huong dan dev-c

Click on the main.cpp

Page 22: huong dan dev-c
Page 23: huong dan dev-c

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 programint 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

Page 24: huong dan dev-c

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

Run the program

Press the Enter key.

Page 25: huong dan dev-c

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.

Page 26: huong dan dev-c

Select the menu item Debug -> DebugThe program starts but is stopped at the breakpoint.The Project1.exe window is displayed but nothing is in the window.

Page 27: huong dan dev-c

Click the Add Watch.

Page 28: huong dan dev-c

Enter i for the integer variable

and click OKDo the same for variable j

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

Page 29: huong dan dev-c

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.

Page 30: huong dan dev-c

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

Page 31: huong dan dev-c

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

Page 32: huong dan dev-c

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

This indicates that the program has finished execution.

Page 33: huong dan dev-c

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

Page 34: huong dan dev-c

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.