Code::Blocks is open source free C, C++ and Fortran IDE that you can use for writing embedded system programs. But before you can use it you must have C/C++ compiler. If you have already installed compiler in your computer then during Code::Blocks installation it will automatically detect and set the correct toolchain path. However if you are new to C/C++ programming then you might not have any C/C++ compilers installed and so you need to install new one. Here is how you can install MinGW compiler that works with Code::Blocks.
When you don’t have any compiler installed and try to build and run the C or C++ code then you will get message like “….The compiler’s setup(GNU GCC Compiler) is invalid, so Code::Blocks cannot find/run the compiler. Probably….. “.
So to install compiler for Code::Blocks follow the steps below.
Download MinGW – Minimalist GNU for Windows from the following url:
Run the installer and it will first install the MinGW Installation Manager.
During installation you will be asked for the installation directory. Set it to default installation path to C:\MinGW because the Code::Blocks IDE looks into this directory by default. You can also put in some other directory. In this case you have to set the toolchain path in Code::Blocks according.
Click on Continue and it will install the manager.
After installation you will see a window which ask you what packages want to install. Select all the packages and mark for installation.
Then from the Installation menu click on Apply Changes.
In the window that again appears click on Apply.
Then the installation will begin. It can take a while depending upon internet speed and what optional packages you selected. After installation you can close the installation manager.
From the Code::Blocks IDE go to Settings then Compilers…
In the window that appears go to Toolchain executables tab. There you can see the path to MinGW compiler as C:\MinGW. Next to it click on Auto-detect.
You should get a message that the executable was detected.
Click on OK and exit the setting window. Now C/C++ project and programs can be compiled.
Build and Run your code and you code should be compiled successfully.