View Course Path

Install Code Blocks, GCC compiler & run your first C program – Windows 10

If you are running Windows, it can be a bit confusing to get Code Blocks to run. Especially if you get mixed up in the GCC compiler installation stuff. Also, if you downloaded only the .exe of the IDE CodeBlock’s official site without the fancy extra files. A few years ago when I was trying to execute my first C program, I ran into a bunch of compiler errors and didn’t understand what was going wrong.

Mind you, this was the first time I was typing code on my computer. I just didn’t know that we were supposed to set up the GCC compiler separately. So I had to configure the compiler manually and it was a bit time-consuming.

In this post, I will try to present a solution to that problem. Just follow the steps below. This the most efficient and the easiest method to get Code Blocks up and running in a jiffy.

What’s the fastest and easiest way to install and set up Code Blocks with the GCC compiler?

Simple. Download this file and follow the steps below. It is preconfigured with the GCC compiler binary files so we will be up and running in a couple of minutes. We will explain the manual process of custom installing the IDE and the compiler later. Not for the sake of efficiency, of course. Just because knowing the intricacies involved in downloading the GCC compiler is a handy tool and will help you understand the basics of setting up IDEs. Select the full installation option from the second installation window.

Once that’s done, a window like the one above should pop-up on your screen. This is the auto-compiler detection window that will locate all the compilers in the installation folder and ask you to select the default one. Select GNU GCC and click Ok.

Technically, this should complete your installation process. However, if for some reason, you don’t see any automatic compiler detection window, here’s what you can do. 

Start code blocks normally. Head on to the Settings drop-down menu and select Compiler. Then inside the settings window, navigate to the tab titled ‘Toolchain executables’. Under the field ‘Compiler’s installation directory’, ensure that the last folder in the selected path is MinGW. Cross-reference with the image below and check if your program files are similarly labeled. That should fix most of the issues with the compiler installation.

The bin folder is where the compiler files are stored. So even if the problem persists even after you select the MinGW folder, it’s probably because the bin subfolder isn’t present. Try doing a fresh re-install on a different hard drive partition.

How to run your first C program in CodeBlocks?

Step 1: Under the tab titles ‘Start here’, click on ‘Create a new project’. This will create a new project folder to store all the different code files.

Step 2: Select Empty project from the different categories displayed in the menu box. Don’t worry about the other options, we will get to know them later in this course.

Step 3: Enter the name of your project, this will be the folder where your individual files will be stored. Also, make a folder on your drive for the code you will write. In the long run, it pays off to organize your files neatly.

Step 4: Make sure that the selected compiler is the one we just installed. Check the boxes as shown in the screenshot to create the debug files.

Step 5: From the topmost toolbar, select the new file icon and create an empty file. This is where we’ll be writing the code. If you can’t see any toolbars, head on to the ‘View’ drop-down, select toolbars and select Main and Compiler, the toolbars should now appear on your screen. Similarly, if you can’t see the Manager window on the left and the Log window at the bottom, you can select to view them from the ‘View’ drop-down.

Step 6: Save the file with the extension ‘.c’ and your desired filename. Notice how the default folder is the project folder we created in step 2.

Step 7: Check the boxes shown below to include the files in the Debug folders.

Step 8: Write the code for Hello World and click the Build and Run icon located in the toolbar on the top. The icon has a yellow gear and a green play logo.

Step 9: You have successfully written your first C program. Join our free C programming course and get better at C!

Are you still having issues with the compiler?

Please comment below and I’ll be glad to help you out. And if you are not facing any problems and have successfully executed your HelloWorld code, don’t get too comfortable, the course is just beginning!

Can I just skip this software and have an online IDE, please?

Yep! You can compile all of your C code in your browser. There are many online IDEs on the web, but this one is my favorite. Using an online IDE just cuts through the hassle when you are not looking for any extra features except executing some code.

18 thoughts on “Install Code Blocks, GCC compiler & run your first C program – Windows 10

  1. Sir if i have created a new folder in c drive and within it i have installed codeblocks then am i supposed to save my files in other drives?..and also where do i save my files in drive c because o am facing the issue where it says compiler not found and one if the reason maybe i am saving files in inappropriate location

    1. You should not be facing any issue in saving your files wherever you want to. I think your compiler is not correctly installed. Check if the GCC compiler is installed. You can do this by firing up your command prompt and entering gcc -version

  2. I followed the steps,but I can not debug programs.It says:
    Starting debugger: C:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet -args D:/Matei/VarianteBacInfo/coada/d/bin/Debug/d.exe

  3. Please post the path where you installed the GNU GCC compiler? You DO REALIZE that Code::Blocks is NOT a Compiler, right? Tim S.

    1. Ofcourse! We will have a separate post on installing the GNU GCC compiler. This post just walks you through installing a version of CodeBlocks that comes pre-configured with the GCC compiler. Once we have the separate post up, we’ll shoot you a mail!

  4. Click the Debugging Windows button on the Debug toolbar and select Watches to enable the Watch pane. (You could also do it from the Debug menu.)

  5. Alternatively, you can place the cursor on a particular line, right-click and select Run-To-Cursor to resume execution up to this line.

  6. Sir My Codeblock has not compailer on starting…..Please inform me that how to compailer download in code block.THANKS

  7. my coddeblocks when i start the application it informs me that i have an issue with my compiler. can you please help

    1. Sure! Could you tell me the installation process you followed? Where did you download code blocks from?

  8. Well, I got it to build, but only by following the direction given in

    Only by choosing “new project”, and “console application”, could it find the include files it needed.

    Why is that? When I tried doing it the way you describe, by opening an empty project, then it couldn’t find the include files. I find that very confusing! Where can I see where the compiler is searching for its include files??

    Thank you.

  9. Thank you for your guide.

    I have just made a full install of codeblocks-17.12mingw-setup.exe.

    I tried entering the hello world! program from the following page

    and choosing “build”, but immediately it said it couldn’t find iostream. I went into the compiler-settings, and could see there were no directories added so it can’t find the header files, etc.

    Why are these not added automatically? What directories do I need to add, in order to compile? Do I also need to add directories to library files? I remember from Visual C++ that I needed to add directories full of *.lib files, but I can’t see any of those in the codeblocks subdirectories.

    Can you help me?

    Thank you.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.