Beginner C/C++ Coding. Installation of Code::Blocks, MinGW, and Your First Loop

Hey everybody,

I wanted to put together a quick but in depth post on setting up your computer (this will be geared towards a Windows 8 OS) so that you can learn to do basic coding. I know that I ran into a tad bit of trouble while installing the MinGW C/C++ Compiler. Hopefully this can act as a straight forward guide for the novice.

SO, first off, you need to understand the basics of what is required and what exactly you are doing. For the basic set-up here I am just going to get you up and running a to the point of running a simple Loop program, and also show you some tips and tricks along the way to help ease that learning curve.

First off you need to Install Code::Blocks and MinGW. These are your coding and compiling programs. Code::Blocks can act as your note pad for writing your codes up, and also is a solid Integrated Development Environment (IDE), while MinGW acts as your “compiler” i.e. it takes what you write and turns it into 1’s and 0’s (binary) which the computer can then understand. Without programs like these you can code all day but your computer will not understand what you are saying. This sounds simple but you can do it a couple of different ways and depending on how you do it some issues can occur.

I personally installed MinGW and Code::Blocks separately. Code::Blocks comes in three different downloads, one of which already has a gcc compiler (MinGW?) in it. I do not know what libraries are downloaded with that and so I went ahead and installed manually to enable more control on my end of what I had available.

Alright, so below we see MinGW opened, you can get it here. There is a ‘Download’ section to the left. Pick the appropriate installer there. Once it opens up you will have to click on the empty boxes for which libraries you wish to install. You can see what I selected below. I also (Not pictured) selected the libraries for C++, since I know I will be using them. You can always come back later and either troubleshoot this portion, or add more libraries for installation. The tab in the top left of the window labeled ‘Installation’ will come down and you can ‘update the catalog’ with your installs you have selected there to finish installation.

MingGW install02MingGW install01

Alright, now although your installation is finished you still need to insert your gcc compiler into your ‘path’ directories. SO, what you want to do is:

  1. Go to you local C: Drive
  2. Double-click MinGW folder (It should be in there)
  3. Double click on the ‘bin’ folder
  4. Click on navigation bar and copy the ‘MinGW\bin’ directory
  5. Go to your PC & right click for properties
  6. Click on the “Advanced System Settings” on the left side of the window
  7. Click on the “Environmental Variables” link
  8. Go down to ‘Path’ and double-click to open system values
  9. Type a semi-colon and paste the copied directory after it.
  10. Press OK, and OK out of the menus.

No worries…I also have some screenshots to aide you through that mess. =D

MinGW install03 MinGW install04 MinGW install05

Now that you have your gcc compiler installed, you can install Code::Blocks here, choosing the appropriate file for your OS. They do a good job of explaining what is in each download. Your compiler will not work without an IDE so you need one of some kind. Below we see the installation wizard start-up for Code::Blocks, and then the installed program opened and awaiting input in the second screenshot. The installation is simple and straight forward. NOTE** It should automatically notice MinGW, and ask you if you would like to have the two programs be associated. You want to make sure they associate so your compiler will work.

CodeBlocks install01 CodeBlocks install02

Once you have all that done, now you want to make sure MinGW is compiling correctly. So use the ‘Windows key’ (henceforth referred to as ‘win’) and ‘x’ shortcut (win+x) to open the menu and click on Run, or if you want to get really fancy just ‘win+R’ to just pull up run. Then type ‘cmd’ in and hit ‘Enter’. Using these types of shortcuts can cut down on a lot of mouse clicking AND lets face it, it is a bit more professional.

Once you have your Command Prompt up, type in the command ‘gcc’ and if it gives you a ‘fatal error: no input files’ then you are up and running!!!

MinGW install06

Congratulations! Now the fun begins.

The most simple of codes you can create is a ‘Loop’. There are a couple different kinds and they can all do different things. There is a plethora of resources to help you from this point via YouTube (Imdad Ahad is a software developer and provides good videos which can walk you through a lot of basic loops and other C programming basics) All these videos were able to catch me up in no time.

If you wish to learn JAVA moving forward (for those website savy peeps) I know a guy who just started his YouTube channel not too long ago. He covers JAVA and some mathematical concepts (fallacies and what-not)  I know him personally and If I ever had trouble understanding something I could blow up his phone. He has always been helpful so be sure to check him out. Oh and he is also writing a textbook on JAVA, so give him a hand and let him know what you think.

I hope you were able to get everything working and as always feel free to e-mail me if you had trouble. I don’t know if I will be able to fix your problem, but I will certainly attempt to aide you in anyway possible.

On a personal note, I have felt the “Hour of Code” videos have been mainly a lot of publicity and not really a lot of true education (at least the ones I have seen). I saw a program through that and it was set up like a video game. That in itself was enough to piss me off to start teaching myself coding a couple years back. I don’t need a graphical copy/paste interface to understand command prompt, but thanks for the vote of confidence. So, as much as their intentions were good, I feel a simple set of Ebooks and Youtube Tutorials via software developers is much more beneficial to the typical adult. Just remember there are a million sources out there, so study up and you will become a C/C++ chieftain in no time!

As always let me know what you think and leave me some comments!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: