Complete Guide: Installing MinGW - Minimalist GNU for Windows for C Language Development

Introduction: MinGW (Minimalist GNU for Windows) is a development environment that enables you to write and compile C and C++ programs on the Windows platform. It provides a set of tools and libraries that are compatible with the GNU Compiler Collection (GCC) to create native Windows executables. In this article, we will guide you through the installation process of MinGW, allowing you to start coding in C on your Windows machine.

Step 1: Downloading MinGW: 

To get started, you need to download the MinGW installation manager, which will help you set up the required components. Follow these steps to download MinGW:

Visit the MinGW website at https://sourceforge.net.


Navigate to the "Downloads" section and click on "mingw-get-setup.exe" to download the installation manager.


Save the file to your desired location on your computer.

Step 2: Installing MinGW: 

Now that you have the MinGW installation manager, follow these steps to install MinGW on your system:

  1. Locate the downloaded "mingw-get-setup.exe" file and double-click on it to start the installation.
  2. In the installation wizard, select the desired installation directory for MinGW. The default directory is recommended.





  3. Proceed with the installation by clicking on the "Continue" button.
  4. Once the installation is complete, close the installation manager.

Step 3: Adding MinGW to the System Path: 

To use MinGW from the command prompt, you need to add it to the system's PATH environment variable. Follow these steps:
  1. On your "Windows Explorer".
  2. Right-click on the "This PC" icon and select "Properties.".

  3. In the System window, click on "Advanced system settings" on the left-hand side.

  4. In the System Properties window, click on the "Environment Variables" button.
  5. In the Environment Variables window, you will see two sections: User variables and System variables. We need to modify the System variables.
  6. Scroll down in the System variables section and locate the "Path" variable. Select it and click on the "Edit" button.
  7. In the Edit Environment Variable window, click on the "New" button to add a new entry.
  8. Now, you need to provide the path to the MinGW bin directory. By default, it is "C:\MinGW\bin" if you used the default installation directory. If you chose a different directory, adjust the path accordingly.
  9. After entering the path, click on "OK" to save the changes and close the windows.
  10. Make sure to restart any open command prompt windows for the changes to take effect.
Step 4: Verifying the Installation:

To ensure that MinGW is installed correctly, follow these steps to verify:
  • Open the command prompt by pressing the Windows key + R, typing "cmd," and pressing Enter.
  • In the command prompt, type "gcc --version" and press Enter. 


  • You should see the version information for the GCC compiler. This confirms that MinGW is installed correctly.



    Congratulations! You have successfully installed MinGW on your Windows machine.

Using MinGW: 

Now that MinGW is installed, you can start writing and compiling C programs using the GCC compiler. 

Here's a simple example:
  • Open a text editor and create a new file. Save it with a .c extension, such as "hello.c".
  • Write the following code in the file:
#include <stdio.h>

int main() {
   printf("Hello, World!\n");
   return 0;
}

  •  Save the file and close the text editor.
  • Open the command prompt and navigate to the directory where you saved the .c file using the "cd" command.
  • Compile the C program by typing gcc hello.c -o hello.exe and press Enter. This will generate an executable file named "hello.exe".
  • Run the program by typing hello and press Enter. You should see the output "Hello, World!" displayed in the console.
Conclusion: 

MinGW provides a convenient way to develop C and C++ programs on Windows. By following the installation steps outlined in this article, you can easily set up MinGW and start coding in C on your Windows machine. Enjoy exploring the world of C programming with MinGW!

Post a Comment (0)
Previous Post Next Post