Source file not compiled in CodeBlocks - C.
Tags: c, cpp
Published: 2020-09-04 07:16:18

If you're someone like me that rarely reads instructions when installing an application then you might definitely meet with the problem I got today and I want to tell you, this might come in handy :+1: .

Initially, I've been a DevC++ application fan and if I was doing anything C i.e the CS50 courses, I would definitely use DevC++ for my C programs.
But today I got the error of **Source file not compiled** for the very first time, got all sweaty, and thanks to [StackOverflow](https://stackoverflow.com/questions/14514682/source-file-not-compiled-dev-c), I managed to get a solution which was *installing CodeBlocks*.

I just went right on to [CodeBlocks](http://www.codeblocks.org/downloads), got the 1st .exe file I could find & installed(clicked Next, Next, finish) without reading through.

I open my C program files and on running:-
> **Source file not compiling** dialog box


1. I came across a guide to [installing and configuring CodeBlocks](https://codeforwin.org/2017/08/install-configure-codeblocks-c-compiler.html) and I figured I really didn't install the setup right.


> *Win + R, type control, uninstall CodeBlocks, Restarted my PC*
and now I was ready to follow the instructions in the above link but still, I didn't reach the part that Enables me to have a **"GNU GCC Compiler"**.

I did the above step for over 4 times but still i got the same error :disappointed: .

Now I started playing with every option in the toolbar till I found a solution :clap: .

:point_right: This will only work if you have set your **Environment variables** like in the link in step 1 or can use these simple steps below:-

- Win + E, file explore opens up
- Go to **This PC**
- Right-click **This PC**, click on **properties**
- On your left, click **Advanced system settings**
- click on **Environment Variables**
- Under **System variables**, click **Path** then **Edit...**
- Browse for the **C:\Program Files\CodeBlocks\MinGW\bin** according to which drive you installed the application.

Now that your Environment variables are set, open your CodeBlocks application to setup my **"GNU GCC Compiler"** as shown below:-


![opened my initial C program in CodeBlocks](https://dev-to-uploads.s3.amazonaws.com/i/n5ia4ny2n8ez8rmnlngo.png)


Next, look for **Settings** menu on the upper toolbar.
![Seetings menu on the toolbar](https://dev-to-uploads.s3.amazonaws.com/i/cn4h4rszw7ryu28qm84o.png)


When you click on Settings, a dropdown menu with Environment,Editor...,Compiler...
![click on Settings, a dropdown menu](https://dev-to-uploads.s3.amazonaws.com/i/035cfnsqfro1mmkf94cv.png)


Select the **Compiler...** menu
![Select the Compiler... menu](https://dev-to-uploads.s3.amazonaws.com/i/t8r3zzae4909414sx15v.png)

After the above step, a new box is opened with **Global Compiler Settings** with the ` selected compiler` *GNU GCC Compiler*.
![a new box is opened](https://dev-to-uploads.s3.amazonaws.com/i/h4s05o1t5pfpaz4ayhgx.png)
![Click Reset Defaults](https://dev-to-uploads.s3.amazonaws.com/i/rh4j3jjr57rgywngxbne.jpg)
Click on **Reset defaults**
![Reset defaults](https://dev-to-uploads.s3.amazonaws.com/i/38c26ablku4m75bmlvmt.png)

A confirmation box pops up, click **Yes**
![confirmation box pops up, click **Yes**](https://dev-to-uploads.s3.amazonaws.com/i/nlhj1mwe35s45tpqjify.png)

Another re-confirmation box pops up, still click **Yes**
![Another re-confirmation box pops up, still click **Yes**](https://dev-to-uploads.s3.amazonaws.com/i/a0cv7l8txgr2e59g94po.png)

Popup box confirming the auto-detect installation of the *GNU GCC Compiler* showing the *Environment Variable* :point_right: C:\Program Files\CodeBlocks\MinGW\bin 
![GNU GCC Compiler all setup using Environment Varaible](https://dev-to-uploads.s3.amazonaws.com/i/p9vdl17g578csqxbgl48.png)

Now it is time to *build and run* your C program :thumbsup: .
![build and run* your C program](https://dev-to-uploads.s3.amazonaws.com/i/rv9qpa1ayh04vrcw4ij6.png)

The program is displayed as shown below
![program is displayed](https://dev-to-uploads.s3.amazonaws.com/i/8zywxziwobv6c5owbfyq.png)

Well, good job on solving that one, *Happy Coding* :smile: and *Thanks for your time* :sunglasses: .