Saturday, June 23, 2012

Code::Blocks IDE for C and C++

The Eclipse IDE is so much work to setup for C/C++ that I investigated alternatives.  I recommend Code::Blocks as a fine tool for learning C and C++:  http://www.codeblocks.org/
The download of Code Blocks comes with MinGW, so you do not need to download MinGW separately.  It also places its copy of MinGW within its own directory structure, so it knows where to find it and it does not interfere with any other installation you have made of MinGW.  I recommend you let Code::Blocks install its own copy of MinGW so it knows where to find it.  Furthermore, with Code Blocks you do not need to modify the PATH environmental variable.  The Eclipse IDE forces you to modify the PATH variable, so Code Blocks is easier to install. 

Once Code Blocks is installed, you can write and compile programs right away.  The only demand Code Blocks makes is that you place the main function inside a file called main.c.

Comparison Between Code Blocks and Eclipse

Eclipse has a "Console" tab that works very well.  For example, on page 18 of the K&R book, there is a line of code that says:
while( getchar( ) != EOF )
When this program is run inside the Eclipse IDE, you can hit the square, red button above the Console window and that acts as an EOF for this program.  The console window in Eclipse is handy.

Code Blocks pops open a Windows command window for output.  If you do a control-C to halt the program on page 18 of K&R, imitating an EOF, then the command window dies and you cannot see the final output of the program.  For programs like this, you need to manually open a Windows command window, maneuver to the program, and execute it manually.  Then you can do a control-C to halt the program, you see the program output, and the command window does not die.  The point is that Eclipse has some advantages over Code Blocks, but they are minimal advantages for beginners.  The ease of installation of Code Blocks is a huge advantage over the complex installation of Eclipse with the CDT plugin.

I do recommend using Code Blocks as a free compiler and IDE for learning C or C++.

About CodeLite

CodeLite is another free IDE for C++:  http://www.codelite.org/
CodeLite, however, is intended for creating GUI applications.  If you are learning to program in C or C++, CodeLite is  not the tool for you.  Avoid CodeLite.

Robert Canright

No comments:

Post a Comment

Comments require my approval before they appear. Be patient. It will take a day or two for your comment to appear.