How To Set Environment Variables for GCC On Windows

How To Set environment variables for GCC On Windows

How To Set Environment Variables for GCC On Windows, Hey There!, Welcome Back to Think & Free. In the previous lesson, I showed you, how to get download and install the GNU GCC Compiler on your Windows System using MinGW. This is part two of How to Install GCC On Windows. In this lesson, I will show you how to Configure Correctly MinGW in Windows System.

Part 1 – How To Install GCC On Windows

Once you correctly installed the GNU GCC Compiler using MinGW on your Windows system. Then you need to Create a Path variable for, getting Access to GCC. Now I’m going to show you how to Create a Path Variable and how to Configure MinGW Correctly. Let’s see how it works.

What are Path Variables?

C:\WINDOWS\system32 is a first path variable in Windows systems. path variable contains executable file locations of programs where it has been located or where it has been installed path in the Windows System. If some program is configured in the PATH Variable it can access anywhere in Windows Systems. That is about PATH Variables. Now we need to create a new path variable for our MinGW installation path before starting working with MinGW.

Create Path Variable & Configure MinGW

Windows Control Panel

First Open up the Control panel window by Start and Search “Control Panel”. And go to System and Security. Now we can see all of the System and Security settings here. Now we need to select System.

Control Panel System and Security

Another way is you Open up the System Configuration Window by simply Going to This PC and Right-click the Icon. Now select Properties. The left side pane on the System Configuration window will provide some Administrator options. Now we need to go to the Advanced system settings in there.

Windows Settings Advanced system settings

Once you tap the Advanced system settings option. You can see another little window will prompt. That is a “System Properties” window. In this window, go to the Environment Variables Under the Advanced Options.

Windows System properties

It will prompt another window, Called “Environment Variables“. Now we are going to create a Path Environment Variable for our MinGW Installation Directory. In the Top of the “Environment variables” Window, you can see the User variable for <USERNAME>, That means these variables are only allowed to the Current user. If you install MinGW Only for you, you can create a PATH Variable here.

Windows Environment Variables

I’m using only for user environment variable option for this time, If you prefer to set environment variables systemwide choose the Edit option in the Path variable under the System variables option.

Creating PATH Variable

Let’s create a path variable under the current user. First Go to PATH under the User Variables, and Hit the Edit button at the bottom. Now You can see the “Edit Environment Variable” window will appear.

Add new user Path Variable

First, copy the full path of the MinGW installation directory. In that location, we can see a directory called “bin“. All binaries will be located in this directory. OK, now select the “New” Option on the Left side top on the “Edit Environment Variable” window.

MinGW Installation Path

It will allow us to add a new PATH Variable. Now Paste, That you copied, The full path of, the bin directory. It is located in the MinGW installation directory.

In my System, C:\MinGW\bin. I’m using the default MinGW installation path. if you change it in the Installation location you must provide it correctly here.

Added MinGW to user variables

Now hit the OK button. Our Path Variable setup process has been completed! Now Hit the OK button in all windows and Close them. Let’s check if our Path variable is working correctly.

gcc version check

Open up a new command prompt window and type gcc –version. it will prompt GCC version information. if you got some message like this. That means The MinGW Configuration setup was successful. If not, check again and create a correct path for the bin directory located in the MinGW installation directory.

I hope you guys enjoy this. if you have questions with this leave a comment.

2 thoughts on “How To Set Environment Variables for GCC On Windows

Leave a Reply

Your email address will not be published. Required fields are marked *