Difference between revisions of "Basic Tutorial"

From Code::Blocks
(Creation. Just the first start and some personal advices of customization)
 
Line 23: Line 23:
  
 
== First start ==
 
== First start ==
 +
=== First steps and basic customizations ===
 
At first start, you will first have a splash screen with the logo of CodeBlocks (later in this text, I will say "C::B". You could see the "CB" word in some places too).
 
At first start, you will first have a splash screen with the logo of CodeBlocks (later in this text, I will say "C::B". You could see the "CB" word in some places too).
 
Just wait a bit and C::B will ask you what compiler you have on your computer.
 
Just wait a bit and C::B will ask you what compiler you have on your computer.

Revision as of 22:28, 2 August 2011


Introduction and other things

This document will try to help you starting with the Code::Blocks IDE (IDE stands for Integrated Development Environment. It mean that it is a software to help you with creating softwares, but remember: it only help, by giving you useful tools and make easier to use them than the command line, it is not a compiler or a debugger! It just help to use them.). As English is not my native language, there will probably have many "translations" errors (not really translation, because I am writing it in English directly...) so do not hesitate to give me reports on the forum! (pseudonym: Freem) If you think something miss, you need enhancement, please, say it too. I can't make a complete tutorial, because I use this tool from many times, and will probably forgot some stuff I'm using every day.

At last, but not least, it's not a tutorial about programming. If you need something like that, please consider searching on the web. As a good hint, I will say www.cplusplus.com, which is my favorite site for searching C++'s easy to read documentation. It have some tutorials too.

Be warned: I am using a nightly build of Code::Blocks, because they are not so hard to install, give many improvements, and are stable enough for use on a daily basis. At least, stable enough for me. So by using the official but old version of Code::Blocks (10.05: more than a year at the moment I am writing those lines). It implies that some menus can have changed and you could have to search for something [u]near[/u] my words, not [b]exactly[/b] my words. Remember: if you want to write programs, you will need to be able to learn by yourself. It's more important than be able to use a technology, because all technologies can evolve! (But I will try to be the more accurate I can).

At last, don't hesitate to try something that is not specified here, I think doing is better than reading. We learn more with a fail, than with a win. If you put the mess in all your Code::Blocks' install, it's not a problem, just remove configuration files and reinstall it. (configurations files are in you user directory. It mean in "%UserProfile%" under windows and in "~/" for unix likes)

Installing Code::Blocks

First, you have to install Code::Blocks. If you are using windows and preparing yourself to your first step in development, I recommend you to install the version bundled with mingw installed. Else (or if you don't mind this advice), you can read them some articles about installing Code::Blocks: Installing_Code::Blocks

First start

First steps and basic customizations

At first start, you will first have a splash screen with the logo of CodeBlocks (later in this text, I will say "C::B". You could see the "CB" word in some places too). Just wait a bit and C::B will ask you what compiler you have on your computer. If you use Microsoft Windows system, and have installed C::B from the installer I recommended in start of this article, you should have the mingw compiler detected. If you are with a Linux distribution, you probably have the GNU GCC Compiler detected.

When you validate, the first compiler detected will be set as default. You could prefer to select another for your common use, just select it then click on "Set as default". If there is no compiler detected, then install one, using an IDE without compiler is not very useful.


When you have validated this first dialog, you will have C::B with a tip of the day. Read those tips can give some useful hints, as this document don't pretend to say everything about C::B. (But I'll try to do my best...) Close it when you have read enough :). If you don't want to have it each time you run C::B, just click on "Show tips at startup"

Second action shall be to rearrange all those tool-bars. There is also one floating... By defaults, they are enabled, but you can remove the by clicking in "View", then go into "Toolbars" and them remove the checked ones (ok, just the one you think are boring). You can also just move them, if you think you'll need them. (In this document, I will use the menu name and write the entry each time) I recommend you to disable them all. In fact, faster you'll learn to search in menus, faster you'll use C::B. And it can help you learn shortcuts... Mouse will often slow you. (about that: as in many applications, ALT+'underlined letter' will often be like a clic on the button/menu)

Some more personal configuration

This section just contain some tips I think good. In fact, if you want to go quickly to your first project, just jump to next section...

I've learned some tips, and have adopted some habits about some settings disabled by default. I will give you some of them as well as highlight some functionalities by the setting options. This is often a good way to start learn how to use a software in details, but never (or only in bad softwares) mandatory:

Environment

  • In "General Settings" for Debian's users, I recommend to set "Shell to run commands in:" as "x-terminal-emulator". It will allow C::B to use the terminal emulator you installed. (I don't like xterm...)
  • in "View" for guys who prefer to have their IDE internationalized, check "internationalization" and give what it need. I guess it is a directory with .po files, but you will have to find/make yourself the translations (I just know there is a French one, but don't remember where. Never used it... If someone know more, about any translations and/or how to enable it, please give me the procedure and links, I'll integrate them here)
  • in "Disabled Dialogs" you will see all dialogs you have disabled, it will allow you to re enable them.
  • "Environment variables" will allow you to modify C::B's variables, and define them in sets. It allow to make easier the management of external libraries.
  • "ToDo list" one of my favorite plug-ins. This menu allow you to include it in the bottom panel. This plug-in will parse something (you can choose: actual file, actual project, or whole workspace) and say you where there are some special comments and what they say, allowing you to never forget to enhance, remove or finish a piece of code. You just have to write a comment with a special syntax (or use the contextual menu in

editor). If you don't like it, or if you are working on a big project, you can disable the auto-refresh here.

  • "Thread Search" will allow you to set-up an advanced search. This search will search (obvious, isn't it?) in a set of file (it can be all opened files, some target files, project's files, workspace'files or files in a directory) a text you want (well, a text or a regular expression pattern, also known as "Regex"). The power of this plug-in, is that it store results in the bottom panel (yes, again...) and allow you to search in all occurrences what you want, because it give you a thumbnail of what is around the thing it have found.
  • "Help files" Another excessively useful plug-in! Here you can add help files in the C::B's context menu. It will allow you, by example, to select a word and press "F1" to have a windows popup with the content of your help about that word. I've tested it with chm files (help files of windows), never tried man or html, but it seem it work too.

Editor

  • "General Settings": here are many useful things. You can modify the size of a tabulation, and specify if you prefer it generate spaces or TAB characters (the advantage of TAB is that when you use arrows, you move faster with tabs than spaces).

You can also enable/disable some customizations about indentation. Personally, I don't like the brace completion, but I like indentation guides, it make it easier to know in what bloc of code you are (you always know in what codeblocs you are, don't you?). The last thing I modify here is the "Highlight line under caret". Useful to know exactly on which line you are, if your caret is far from begin or vice versa (lines are very long and your caret is at it's begin)

  • "Margin and caret" here you can gain some place with the line numbers. A useful option (really, for those as useful as this one, I don't know why they are not default... but C::B's dev have so many work and private life, but took time to gave us those nice options so it's ok, don't you agree?) is the "Dynamic setting" at first line. It will allow the width to be optimal. Just enough to write the full line number, not less, not more: no waste of space and a nice look about your position!.

Next is the "Right margin". Not so useful if you work alone on a wide screen, but when you work in some project with other people, it can happen that a coding convention forbid you to have more that, by example, 80 char width. This setting help you with that. (this rule can be useful for people who don't like word wrap or scrolling, and can sometimes work on a portable computer, in holly-days or travels.) There is also some options about advanced selections: "Enable virtual space" which will allow you to have something like a paper, you can place your caret everywhere you want, without placing many spaces. And the "Allow multiple selections" with the sub option "Enable typing (and deleting) in multiple selections simultaneously", to be able to alter many lines with only one type. Useful when you use some copy/paste or are writing some switch cases...

  • "Syntax highlighting" will allow you to use C::B for another language, and customize some highlights. (on some screen (like my netbook), there are some comments which are impossible to read due to low contrast. To solve the problem, it's here!)
  • "Default code" will allow you to insert automatically some code when C::B generate a file (like a class or header). Can be used, by example, to insert licensing (common when you look into GPLed sources)
  • "Incremental search settings" this menu allow you to customize the incremental searches. What is it? Incremental search are searches which highlight results. You have something like that is some web browsers, by example. When you type, the software search about what you are writing and highlight it to avoid you passing through it without seeing.
  • "DoxyBlocks" well, another very useful plugin. This one allow C::B to generate comments for doxygen, and drive doxygen to generate the documentation about your code (doxygen is a free software). I recommend you to use this if you don't actually, because the lack of comments often give you many hours of useless work.

This setting panel is like a simplified doxygen GUI.

  • "Code completion" one of the main features of an IDE. The code completion allow you to "summon" the rest of the word you are typing, or give you some nice hints, because coders are not machines: we don't have random access to all our memory, or don't want to remember everything about each piece of code we wrote. So Code completion, or CC help us. Here are some options to customize it. I like to enable the "Auto-select, if only one match", and removing the "automatically launch when typed # letters" because I use CTRL+SPACE to invoke the feature. For "Keywords sets to additionally include", I have to admit I don't know what it mean, so I let it by default.
  • "keybord shortcuts" can be useful, if, like me, you don't really like to rub your desktop with your mouse.
  • "Source formatter" also know as AStyle. This plugin simply reformat your code. If you take some code of someone else, or produced by a code generator, just run this plugin to have your code formatted to your preferences. Well, you need to setup them before, obviously. But the most common styles are already implemented, so you'll probably just have to select one them and let's go!
  • "Browse tracker" this plugin allow you to navigate quickly in your code thanks to some keyboard shortcuts.
  • "WxSmith Settings" this is the RAD plugin of C::B, allowing to quickly draw a wxWidget application. Some nice (for me) customizations here are "add new items continuously", setting "proportion" to 0 and enabling "expand". But these are my options...