Setting up MinGW, GCC and Notepad++ on Windows
Downloading and Installing MinGW and GCC
Go to the MinGW download site
Go into the Installer folder and download the file mingw-get-setup.exe.
Run the downloaded file on your computer, accept all the default settings and continue. You should get the following screen:
Click on “Continue” and the MinGW Installation Manager will open and look like this:
Mark the following packages for installation
Click on Installation->Apply Changes.
The installer will then download the needed packages. Your screen will look like this:
Once the installation is complete, the following confirmation screen will show:
Click on “Close” and exit the MinGW Installation Manager.
Download and Install Notepad++
Go to the Notepad++ download page:
Download Notepad++ Installer.
Run the Installer and accept all the default options to install Notepad++.
You should now be able to run Notepad++ from the Start menu.
Setting up the system for programming
First of all create new folder on your disk to keep all the programs separately. Lets say you create it in your C drive can call it “code”.
Since MinGW was installed using default options, it should be in the C:\MinGW folder.
We will now create a short batch file to setup the command prompt to work with MinGW.
Open Notepad++, create a new file with just the following command:
Save the file as “setup.bat” in the folder c:\code.
Now you are ready to edit and compile programs.
How to edit and compile programs
Open Notepad++, write your program there and save it in the C:\code folder. Lets say the program is called “sample.c”.
Open the Windows Command Prompt. Change to the code folder by typing:
Setup the command prompt using our batch file like this
You can now compile your program like this:
If there are errors, you will have to go back to Notepad++ to change the code.
If compilation succeeds, you will see the file a.exe created in the same folder.
Run the program like this:
By default every successful compilation will result in a.exe getting created and overwritten for every subsequent compile. If you want a different name for your compiled program, you should add the output file name to the gcc command like this:
C:\code>gcc -o sample.exe sample.c
And then run the program like this:
That’s it !! You are ready to code.
You only need to run the setup.bat file once when you open the command prompt. After that the settings will stay until you close that command prompt.
For fast switching between editing the code in Notepad++ and compiling on the command prompt, keep both open and keep switching using Alt+Tab. Like this screen: