Você está na página 1de 64

Code::Blocks Student Manual

Lawrence Goetz, Network Administrator Yedidyah Langsam, ro!essor and "heodore #a$han, %istinguished ro!essor %e$t& o! Com$uter and 'n!ormation Science Brooklyn College o! C(NY
) *++,-*++. /ersion .&+*
0 o! ,1

Table of Contents
'ntroduction&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&2 'nstallation o! Code Blocks&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&1 Ste$ 0: %ownload the So!tware&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&1 Ste$ *: 'nstall the So!tware&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&3 Ste$ 2: Customization o! the Code::Blocks (ser 'nter!ace 45$tional6&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&. 7irst ro8ect&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&02 Adding 7iles "o Your ro8ect&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&** %e9ugging a rogram&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&10 '! you are using the Mac 5S, you will need to do the !ollowing:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,* re-'nstall ste$s:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,* A$$endi: A: 'nstalling Code::Blocks under Mac 5S ; and Linu:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,* 'nstallation !or 7edora . Linu::&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,2 'nstallation !or (9untu Linu::&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,2

* o! ,1

Introduction
"hrough the aid o! a compiler, a $rogram written in a com$uter language, such as C<<, is turned into machine code, which is e:ecuted on the com$uter& =owe>er, going !rom an idea to a $rogram that works success!ully takes a lot o! time and e!!ort& 't may take se>eral rewrites o! code to get the $rogram to work correctly& "o accom$lish this, students must learn a disci$lined a$$roach to organizing the code and learn how to trace their $rograms& "he $ur$ose o! this manual is to hel$ the student de>elo$ the skills to organize $rogram coding and de>elo$ sound techni?ues !or !inding and isolating errors& =ere you will learn how to trace the code ste$ 9y ste$, so that it 9ecomes clear where the $ro9lem is and why your $rogram does not e:ecute $ro$erly& "his is called debugging the $rogram& =and tracing is use!ul in hel$ing 9eginners understand where the 9ugs are and correct the $rogram a$$ro$riately& Automatic tools ha>e also 9een de>elo$ed to hel$ you trace $rograms that you ha>e written and will 9e an im$ortant tool as your $rograms 9ecome more com$le:& "his ty$e o! tool is called a debugger& A de9ugger lets you $ause a $rogram, while it is in the middle o! running, and watch what is going on& Some de9uggers work as command-line line de9uggers, 9ut newer de9uggers ha>e a nice gra$hical user inter!ace, which is use!ul in hel$ing you watch >aria9les that you ha>e de!ined as the $rogram e:ecutes& "he gra$hically9ased de9ugger en>ironment is $art o! what is called the Integrated Development Environment (IDE)& "he $ur$ose o! these notes is to introduce you to this en>ironment and hel$ you learn how to use it as you de>elo$ and hone your $rogramming skills& A de9ugger cannot sol>e your $ro9lems !or you& 't is merely a tool to assist you when $rogramming& You should !irst attem$t to read o>er your code and using $a$er and $encil analyze the code to get an understanding o! what is going on& 5nce you ha>e gotten an idea o! where in your code you ha>e an error, you can then set the de9ugger to watch certain >aria9les in your $rogram& @atching your code will show you ste$ 9y ste$ how your $rogram is 9eing e:ecuted& "he de9ugger that you will use is $art o! an 5$en Source !ree '%A called Code::Blocks, which we ha>e !ound easy to use and is descri9ed in these notes& Code::Blocks has a C<< editor and com$iler& 't will allow you to create and test your $rograms !rom one easy to use a$$lication& @e ho$e these notes will assist you in making $rogramming more en8oya9le and hel$ you de>elo$ 9etter $rogramming skills& You may !ind additional in!ormation regarding Code::Blocks at: htt$:BBwww&code9locks&orgB A com$lete manual !or Code::Blocks is a>aila9le here: htt$:BBwww&code9locks&orgBuser-manual

2 o! ,1

Installation of Code Blocks


tep !: Download the oftware
'n order to install the Code::Blocks '%A as well as the MinG@ com$iler, you must download it& '! you are using either "indows #$ or "indows %ista download the installation $rograms !rom here: htt$:BBdownloads&source!orge&netBcode9locksBcode9locks-.&+*mingw-setu$&e:e Sa>e the !ile to your hard disk and remem9er its location& roceed to the ne:t $age in order to continue the installation& '! you are using Mac 5S ; or Linu:, $lease see A$$endi: ' !or installation instructions&

1 o! ,1

tep &: Install the oftware


Ne:t, o$en 4click on6 CodeBlocks install !ile and the CodeBlocks Setu$ will 9egin installing as !ollows:

Click 'e(t)

3 o! ,1

Select I *gree&

"ake the de!ault settings 9y $ressing 'e(t&

, o! ,1

"ake the de!ault !older to install CodeBlocks to and then select 'nstall&

C o! ,1

tep +: Customi,ation of the Code::Blocks -ser Interface (.ptional)


"he !ollowing ste$s will ena9le you to customize your '%A so that it is will 9e consistent with what your instructor will 9e using in class: 0& Con!igure the editor: a& 9& i& ii& Your screen should now look like the !igure: Choose Editor !rom the Settings Menu (nder the General Setting ta9 Change the !ont size to 0+ or 0* $oint 4(se the Choose 9utton&6 (nder Other Options $lace a check mark the !ollowing o$tions: DShow line num9ersE Dhighlight line under caretE Dhighlight occurrencesE

. o! ,1

c& i& ii&

Select the Margins and Caret ta9 on the right o! the window& Choose D/isi9le lineE !rom the Right margin hint Set the Hint Column to C*

Your screen should now look like the !igure:

F o! ,1

0+ o! ,1

d& i&

Choose the Source !ormatter Caret ta9 on the right o! the window& Select K&R !rom the style menu 4Note: Your instructor may use a di!!erent style G i! so, e:amine each style and choose the style that matches your instructorHs $re!erred indentation&6

Your screen should now look like the !igure:

e)

Choose OK in order to sa>e your customizations&

00 o! ,1

&)

Con!igure the Help !iles a& 9& c& d& e& !& g& h& %ownload the C<< hel$ !ile !rom htt$:BBonner9y&seBIdanielBchmBc$$re!erence&comBc$$&chm Sa>e the c$$&htm !ile to your c:B rogram 7ilesBCode9locks directory A!ter sa>ing the !ile, right-click on the !ile, choose Properties, and un9lock the !ile so that it will 9e accessi9le to the Code::Blocks '%A& Choose Environment !rom the Settings Menu 5n the ta9 to the le!t o! the window scroll down to the Help Files section Choose Add and enter DC<< =el$E (se the !ile 9rowser 9utton to locate the !ile you ha>e 8ust sa>ed& 4't should 9e at C:J rogram 7ilesJCodeBlocksJc$$&chm6 lace a check mark in the this is the de!ault hel$ !ile 4Shortcut: 706

Your screen should now look like the !igure:

i)

Choose OK in order to sa>e your customizations&

By $ressing 70 you will now 9e a9le to o9tain hel$ on the word under your cursor& 0* o! ,1

7irst ro8ect
A!ter you ha>e !inished downloading and setting u$ the Code::Blocks system, you can 9e in to write code& Code::Blocks creates what is called a "orkspace to kee$ track o! the pro/ect you are working on& 't is $ossi9le !or you to 9e working on multi$le $ro8ects within your works$ace& A pro/ect is a collection o! one or more source 4as well as header6 !iles& ource !iles are the !iles that contain the source code !or your $rogram& '! you are de>elo$ing a C<< $rogram, you are writing C<< source code 4&c$$ !iles6& 0eader !iles are used when you are creating librar1 !iles 4&h !iles6& A librar1 is a collection o! functions that are called to $er!orm s$eci!ic tasks, such as doing math, etc& Setting u$ a pro/ect allows you to kee$ track o! all the !iles in an organized way& @hen !irst starting out in com$uter $rogramming, generally your $ro8ects will consist o! a single source !ile& =owe>er as you gain e:$erience and work on more com$le: $ro8ects, you will ha>e $ro8ects containing many source !iles and dealing with header !iles as well& "o create a $ro8ect, click on the 2ile $ull-down menu, o$en 'ew and then $ro/ect&

02 o! ,1

"his will 9ring u$ the 'ew from template window& 5$ening 4clicking on6 Console *pplication will then allow you to write a $rogram on the console& "he other a$$lication are !or de>elo$ing more ad>anced ty$es o! a$$lications& A!ter selecting Console application3 click on the Go 9utton to 9egin using the Console A$$lication @izard&

01 o! ,1

ress Ne:t to go to the ne:t ste$&

03 o! ,1

"he ne:t window allows you to choose the language that you will use& Select the language as C<<, then $ress 7inish&

0, o! ,1

Start 9y !illing in the ro8ect "itle& You will notice that the ro8ect 7ilename automatically 9ecomes the same name& '! you wish, you can change the !ilename, 9ut !or sim$licity lea>e it as is& "o s$eci!y the location o! the !older to contain the $ro8ect, click on the D&&&E 9utton 4selected in the $icture a9o>e6 and 9rowse to a !older on your dri>e to store the $ro8ect& Generally, you can sa>e it in My %ocuments& ress Ok a!ter selecting My %ocuments

0C o! ,1

@hen the directory !or your $ro8ect has 9een selected, the system will return to the Console application& As shown, Code Blocks will create a directory called 7irst rogram 4 ro8ect "itle6 and returns your selected directory in 2older to create pro/ect in& 'nside that directory will 9e the ro/ect filename 47irst rogram6 and a resulting !ilename, which contains a Code Block ro8ect !ile 4&c9$6 named 7irst rogram&c9$& "he $ro8ect title and $ro8ect !ilename in this case are the same& =owe>er, they need not 9e the same and these names can 9e altered& Click on the Ne:t Button when done&

0. o! ,1

"he ne:t window to $o$ u$ will 9e the Com$iler screen& "his s$eci!ies where the Debug and 4elease com$iled >ersions o! your $rogram will 9e $laced& Lea>e this setting alone and $ress Ne:t&

0F o! ,1

"he system will then return to the 52irst $rogram6 window and you are ready to write your $rogram& 't should 9e noted that the Build target is Debug, which will allow you to use the de9ugger to !ind errors& 'n the 7anagement area o! the screen 4Shi!t-7* toggles the Management dis$lay6, you will see the !iles that are $art o! the $ro8ect in the $ro/ects ta9& "o see the source !iles, click on the $lus K<LHs to e:$and the "orkspace and its su9directories&

*+ o! ,1

(nder Sources, there is a !ile called main&c$$, which is automatically created !or you when you 9uild a console a$$lication&

*0 o! ,1

Adding 7iles "o Your ro8ect


'! you ha>e a $ro8ect with additional e:isting !iles, go to the ro8ect menu and select DAdd !iles&E "his will 9ring in the !iles associated with your $rogram& You also ha>e the o$tion to 4emove files, $er!orming Build options and to et programs8 arguments9&

** o! ,1

Clicking on *dd files to pro/ect3 will 9ring u$ a window so you can 9rowse to where your !iles that you wish to add are) Select any additional !ile you want to add and $ress 5$en& "he !ile will then 9e added to your $ro8ect& '! you are creating a new !ile, you can use the $ull-down 2ile menu and o$en an empt1 file& 7ile, New, Am$ty !ile&

*2 o! ,1

You will 9e asked i! you want to add this !ile to the $ro8ect&

Choose Yes& Code Blocks will ask !or a !ile name to sa>e the !ile as:

*1 o! ,1

Gi>e a name to the !ile& ick a name that is related to the content o! the !ile& =ere it is called sam$le&c$$& C<< !iles need to 9e o! the ty$e c$$& ress Sa>e to sa>e the !ile&

ress Select All to ha>e this !ile sa>ed as 9oth %e9ug M #elease targets& ress OK when done& A target is a ty$e o! com$iled >ersion& You can work with a de9ug target, which will allow you to test the $rogram using a de9ugger& A de9ug target will 9e large in size, 9ecause it has e:tra in!ormation in it to allow you to test !or errors& A release target is smaller in size, 9ecause it does not ha>e the de9ugging in!ormation& @hen you are ready to gi>e other $eo$le 4such as your 'nstructor6 your !inished $rogram, you should gi>e them the release target&

*3 o! ,1

"he Sources now has sam$le&c$$ as a source !ile in addition to the main&c$$ !ile& Since the sam$le&c$$ is not needed !or your $ro8ect, $lease remo>e it&

*, o! ,1

7rom the ro8ect menu select, #emo>e !iles&

lace a check mark ne:t to any !ile4s6 that you wish to remo>e& ress OK when you are done&

*C o! ,1

You will need to con!irm that you wish to remo>e the !ile4s6& ress Yes, i! you are sure you want to remo>e them& 5therwise $ress No&

You will now see an u$dated listing o! the Sources in your !ile& You should now see only Main&c$$& 'n the 5$en 7iles list, there may 9e a !ile called N-ntitled) $lease ignore this)

*. o! ,1

"o edit a !ile !rom your $ro8ect, dou9le click on itOs name !rom ources and it will a$$ear in the window with line num9ers& You can now edit the !ile and $re$are your $rogram&

*F o! ,1

'n order to check that %e9ug is running, you can use the $ro/ect $ull-down menu and click on Build .ptions)

2+ o! ,1

@hen this is done, the $ro/ect Build options window will come u$& Make sure that the $roduce debugging s1mbols 5:g6 is checked& ress OK when done&

20 o! ,1

A!ter clicking on done, the system will return to Main&c$$& "hen testing 1our code3 make sure that Debug is selected as the target to use) "his way when you Compile your $rogram, you will ha>e a %e9ug >ersion a>aila9le& "o com$ile a !ile means to take the instructions that you ha>e written and translate it into machine code !or the com$uter to understand&

2* o! ,1

Com$ile your !ile !rom the Build $ull-down menu 9y clicking on Compile current file 4Ctrl-Shi!t-7F6&

22 o! ,1

"est the $ro8ect !rom the Build ull-down menu, 9y clicking on Build and #un& "his ste$ will build an e:ecuta9le !ile !or you& A $ro8ect 9uild will take the com$iled >ersions o! your source !iles and com9ine them into one $rogram& You are a9le to $ress 7F, which is a key9oard shortcut that will 9uild your $ro8ect and run it at the same time& As you gain more e:$erience with the system, it will 9e easier to 8ust $ress 7F to Build M #un your $rogram& "he Message window will indicate i! there are any errors during a com$ile or 9uild $hase&

21 o! ,1

"his is the out$ut !rom my !irst $rogram& Notice that 9esides dis$laying D=ello worldNE it also says to D ress any key to continueE with the $rogram $aused& ressing any key will e:it the $rogram& '! you e:ecute the $rogram 9y going to a console window you will not see the D ress any key to continueE message:

Notice that there are dou9le ?uotes around the !ile name& "his is 9ecause there is a s$ace in the name& '! you e:ecute this $rogram 9y dou9le clicking on itOs icon, the $rogram would close right away& "hat is 9ecause the $ause statement is only done when you run your $rogram in Code Blocks& 23 o! ,1

@hen you are done, sa>e all your !iles 9y $ulling down the 2ile menu and clicking on ave all files&

2, o! ,1

Now you can select to sa>e the $ro8ect:

@hen you e:it the $rogram, you may 9e asked to sa>e the "orkspace and the ;a1out& "he Layout re!ers to the $lacement o! >arious windows that you may ha>e $ositioned& Generally you would select to Sa>e the Layout 4unless you know you really do not want it sa>ed6& "he @orks$ace re!ers to the $ro8ects you are working on& 't is $ossi9le !or you to 9e working on multi$le $ro8ects within your works$ace& Sa>ing your works$ace will allow you to return to the same set o! $ro8ects when you ne:t o$en Code Blocks&

2C o! ,1

"o o$en a $ro8ect

7rom the 7ile menu select 5$en&

2. o! ,1

7rom the 2iles of t1pe: in the window, select DCode::Blocks $ro8ect !ilesE and then select the &c9$ !ile $ertaining to your $rogram& ress 5$en when done&

2F o! ,1

"he $ro8ect has reo$ened& You can get more s$ace to see your $rogram, i! you close the 7essages window& ressing 2& toggles the dis$lay o! the messages& "he 7essages window has 9een turned o!! !or the remainder o! this tutorial, to allow more s$ace to 9e >isi9le on the screen& Note: You may also o$en a $ro8ect directly !rom @indows A:$lorer 9y dou9le-clicking on the !ile with the &c9$ e:tension&

1+ o! ,1

%e9ugging a rogram
As your $rograms 9ecome more com$licated, there will 9e a need to trace the $rogram e:ecution ste$ 9y ste$ or $lace 9reak $oints where you wish the $rogram to $ause& "his is where a de9ugger is utilized& A de9ugger can $ause your $rogram and you can watch the >alues o! the >aria9les that you ha>e de!ined& "he !ollowing is a sam$le $rogram that can 9e traced Dline 9y lineE while watching what ha$$ens as each line o! code is e:ecuted&

10 o! ,1

7irst, it is necessary to set a $lace in the code to ha>e the $rogram $ause& "his is done 9y using the Debug $ull-down menu and clicking on 4un to Cursor) The cursor should be over the first line of code where 1ou wish to start the tracing process) This starts the debugging process)

"he ne:t ste$ in de9ugging a $rogram is to tell the $rogram when to sto$ running so you can ins$ect the results& "o do this, $lace the cursor o>er the line where you want your $rogram to sto$& 7or e:am$le, the cursor was $laced at line 0. 4which is hidden 9ehind the menu6& "his is called a Breakpoint) Now you can instruct the de9ugger to run the $rogram u$ to the cursorOs $osition 4line num9er6&

1* o! ,1

"he $rogram will generate a 9lank window& 't is 9lank, since that $rogram has yet to e:ecute any line that dis$lays something&

12 o! ,1

"o watch certain >aria9les during the e:ecution o! the $rogram, you should o$en the @atches window& "his will show you the >aria9les in your code& "his is accom$lished 9y going to the Debug $ull-down menu and clicking on Debugging "indows and then "atches&

11 o! ,1

"hese are the watches that the de9ugger is dis$laying& Notice that x M y ha>e the correct >alues& /aria9le z has not 9een assigned itOs >alue on line 0. yet& "he current >alue is a random >alue&

13 o! ,1

Line 0. has a yellow marker on the le!t side& "his indicates that the $rogram has $aused on that line, which is the 9reak$oint&

1, o! ,1

"o determine how your $rogram will !unction when calling !unctions such as: z = addem(x,y); tep info 4Shi!t-7C6 can 9e selected !rom the %e9ug $ull-down menu&

1C o! ,1

"he ne:t ste$ is line F&

1. o! ,1

"he arguments a and b are shown in the @atches window& Notice that the local >aria9le c, which has not 9een set yet, has a random >alue&

1F o! ,1

"o $roceed to the ne:t line o! code, select 'e(t line !rom the %e9ug menu& ressing 2< is a use!ul key9oard shortcut and will 9ecome second nature as you 9ecome !amiliar with the system&

3+ o! ,1

"he de9ug window re!lects the change o! c&

30 o! ,1

@hen you are done de9ugging, you can click on Continue and 1our program will run to completion) "his is 9etter than selecting to top debugger& "he reason it is 9etter to Continue, is 9ecause the $rogram comes to a natural end, rather than a9orting& =owe>er i! your $rogram is stuck in a loo$, or you are sure you can e:it sa!ely, you can select !rom the %e9ug menu top Debugger&

3* o! ,1

You can !urther de!ine $laces in your $rogram to $ause and allow you to ins$ect the code& "his is done 9y setting 9reak$oints in your code& You can ha>e zero or more 9reak$oints in your code& @hen the de9ugger encounters a 9reak$oint, the $rogram $auses and the de9ugger will allow you to ins$ect your code& The breakpoint remains until 1ou remove it) It can be Toggled with 2=)

32 o! ,1

A 9reak$oint has 9een set at line F& "he red circle indicates that there is a 9reak$oint in the code&

31 o! ,1

"he $rogram is started 9y selecting !rom the Debug $ull-down menu, tart& "his will run the $rogram in the de9ugger until a 9reak$oint is encountered, at which $oint the $rogram will $ause&

33 o! ,1

@hen the $rogram $auses at the 9reak $oint, a red circle with a yellow triangle mark will a$$ear at the 9reak$oint&

3, o! ,1

You can set multi$le 9reak$oints& "he key9oard shortcut 2= allows you to toggle the 9reak$oint at any line&

3C o! ,1

"his screen shows 9reak$oints on lines F and 0F, 9ut line F indicates that the code has e:ecuted to that $oint&

3. o! ,1

Selecting Continue !rom the %e9ugger menu will run the $rogram till the ne:t 9reak$oint&

3F o! ,1

Now the $rogram sto$s at line 0F, 9ecause the $rogram reached the second 9reak$oint& ress Ctrl-7C to continue& Now the $rogram runs till the end o! the $rogram, 9ecause there are no !urther 9reak$oints to encounter&

,+ o! ,1

@hen you e:it Code:Blocks you may 9e $resented with the !ollowing window&

Say DYesE to sa>e the @orks$ace& "his sa>es settings o! the works$ace you are working on& You now know the 9asics o! how to use the com$iler, work with a $ro8ect, and use the de9ugger& Good luck with your $rogrammingN

,0 o! ,1

A$$endi: A 'nstallation o! Code::Blocks !or Mac 5S ; and Linu:


If 1ou are using the 7ac . 3 1ou will need to do the following: $re:Install steps:
=ere is a ste$ 9y ste$ instruction !ile !or setting u$ ;00 and ;code"ools !or the Mac& 0& Make sure that #!! is installed in your system 4check in your A$$lication menu6& '! not, youOll need to install it !rom your Mac 5S disc&
o

'nsert the disc and !ind the o$tional $ackages installer, o$en it, check the ;00 9o:, and install !rom that& '! you are using 0+&0 through 0+&2, you can download ;00 !rom A$$le&

*&

Install Developer Tools: You ma !e a!le to skip this step" i# ou are using $a% OS & '()* +iger and have installed the ,eveloper tools&
o

As a test, o$en u$ (term& You cannot use terminal with Code Blocks& :term is $art o! ;00 and that is why youOll need to ha>e ;00 installed& #un the command gcc& '! you get an error that there are no in$ut !iles, that means gcc e:ists and you are good to go& '! you get an error saying the command is not !ound, you need to install the %e>elo$er "ools& '! you need to install the %e>elo$er tools, you can download them !rom A$$le, or you can install them !rom your Mac 5S disc) Locate the ;code installer on the installation discs and dou9le click to install& Check your discs !or ;code or %e>elo$er "ools& 4un the installer and install ever1thing other than the documentation:

7or Mac 5S ; 0+&2, you need to install ;code "ools >ersion 0&* or later 7or Mac 5S ; 0+&1, you need to install ;code "ools >ersion *&* or later

,* o! ,1

7or Mac 5S ; 0+&3, you need to install ;code "ools >ersion 2&0 or later

Download Code::Blocks) -ncompress the ,ip file and place CodeBlocks)app where 1ou like it) The suggested location is >Developer>*pplications or ?>*pplications)

Installation for 2edora @ ;inu(:


'nstalling Code::Blocks 'n a console window, 9ecome root and then e:ecute the !ollowing command: 1um install codeblocks #unning Code::Blocks 'n the A$$lications ull %own Menu, go to rogramming and click on: Code::Blocks '%A or 5$en a console window and then e:ecute the !ollowing command: codeblocks

Installation for -buntu ;inu(:


'nstallation 'nstructions 7rom: htt$:BB!orums&code9locks&orgBinde:&$h$Bto$ic,.*+.&msg,0+.3&htmlPmsg,0+.3 !) *dd the repositories to >etc>apt>sources)list: 5$en the !ile with a gra$hical editor as root& aste the !ollowing line in a terminal:
gksu gedit /etc/apt/sources.list

# codeblocks deb http://lgp2 !."ree."r/ubu#tu/ gutsy u#i$erse # %x %idgets deb http://apt.%x%idgets.org/ gutsy&%x mai# Note: Depending on what version of Ubuntu you are using, in step 1 you may need to replace gutsy with feisty.

aste this at the end:

&) To make sure 1our package s1stem trusts these sources) *dd their ke1s) Anter these two lines at the terminal:
%get &' http://lgp2 !."ree."r/public.key &(& ) sudo apt&key add & %get &' http://apt.%x%idgets.org/key.asc &(& ) sudo apt&key add &

And u$date the $ackages 9y entering the !ollowing lines on the terminal:
sudo apt&get update sudo apt&get upgrade

,2 o! ,1

+) Install Code::Blocks Anter the !ollowing line in the terminal:


sudo apt&get i#stall libcodeblocks codeblocks lib%xsmithlib codeblocks&co#trib

You are a9le to ste$ 2 whene>er you want you to get the latest nightly 9uild& You should see Code::Blocks in the rogramming Languages listing o! your $rograms&

,1 o! ,1

Você também pode gostar