turrier.fr

Source : ct|23.04.08

< Tutorials Computer, Multimedia, Chinese

Install and use Code::Blocks

Introduction

CodeBlocks is a free integrated development environment, permitting to realize programs in C or C++ language. It comprises a text editor, a compiler and a debugger. It is distributed under GPL licence and can be used freely.

image1

Install and use CodeBlocks

CodeBlocks can be downloaded to the addresse "codeblocks org". You can localize easily this site tapping «codeblocks » in the textual zone of the Google search motor.

image2

To the date of creation of this tutorial, you must, if you are under Windows, download the file "codeblocks-8.02minw-setup exe" (19,3MB) who contains the compiler and the debugger (and not the file "codeblocks-8.02-setup exe", who does not contain those tools).

image3

If you are under Linux or under Mac OS, download corresponding files. Once the file "codeblocks-8.02minw-setup exe" is downloaded on your computer, execute him and follow the install procedure. Once this one is terminated, Codeblocks is accessible from the Start menu of your computer.

image4

Realize a first program

1) Start Codeblocks, then do «File/New/project ».

image5

2) Choose "console application", then click « Go »

image6

3) Choose « C » (to realize a program in C language), then click Next.

image7

4) Choose a name for your project ("essai" for example ) and a destination directory (C:\ for instance ), then click « Next ».

image8

5) In the dialog box which opens , verify that the compiler "GNU GCC" is chosen (This is the used compiler by Codeblocks and is part of the CodeBlocks package). Click « Finish ».

image9

6) The project, his structure and the CodeBlocks generated program appear then in the window of the development environment.

image10

image11

7) Compile this programs and start his execution clicking « Build/Build and run ». The console window opens then and the program runs. In the used example the program displays only « Hello word ! »

image12

image13

8) Verify the presence of the files constituting the project in the "C:/essai" directory. To the root of this directory, you must find : main.c (source file, containing the program in C language ), essai cbp (project file used by Codeblocks) and, in the "C:/essai/bin/Debug" directory, the executable file "essai exe".

image14

image15

If you click directly on this file, without passing by the development environment, you will establish that the window of the program opens and closes immediately. How to explain that ? The explanation is simple, the program displays « Hello world !» and terminate immediately. Those actions are effected so rapidly that you have not the time to see the window and the message inside this one . Why this problem has not place when one throws the program directly for the development environment? Simply because the development environment maintains himself the window of the terminated program. To correct this problem, it suffices you to insert the instruction system ("pause") in the listing, at the end of the program, and to recompile him. You can then run directly the executable file, without meeting the preceding problem.

image16


Valid XHTML 1.0 Transitional

© http://turrier.fr (2007)