The term 'gcc' is not recognized as the name of a cmdlet, function...

The term 'gcc' is not recognized as the name of a cmdlet, function... C , C++ compiler not found issue.

2025-03-09 07:58:40 - Admin Sarwar

gcc: The term 'gcc' is not recognized as the name of a cmdlet, function...


If you've ever seen the error message 'The term gcc is not recognized...' in VS Code or another IDE/Terminal, you know how confusing and disruptive it can be. This common problem can stop you in your programming tracks, but the solution is often simpler than it seems.

Computer programming coursegcc : The term 'gcc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ gcc
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (gcc:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Copy

The error "‘gcc' is not recognized as the name of a cmdlet, function, script file, or operable program.” occurs for two primary reasons:

  1. Reason 1: Absence of the gcc compiler on your computer. The solution is to simply install it
  2. Reason 2: The Compiler path is not included in your system’s ‘PATH’ environment variable

In previous Windows versions, the error looked like this: "'gcc' is not recognized as an internal or external command, operable program, or batch file."

This straightforward guide will provide the solutions to address this problem on the Windows platform.


Solution 1: Install MinGW Compiler:

If you do not have MinGW Compiler installed in your system, you need to install it from here. MinGW is a native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications.

We have already covered the installation of MinGW in another blog. Check this blog out for installing MinGW in your system.


Solution 2: Set up the environment variables:

After installing MinGW, along with the gcc and g++ compiler packages, you must set the PATH variable on your computer.

  1. Click on your search icon beside the windows icon and type "Environment Variables"


  1. cwh blog image
  2. Click on the first option "Edit the system Environment Variables". A System Properties window will open. Click on "Environment Variables"
  3. cwh blog image
  4. Select Path and click on "Edit"
  5. cwh blog image
  6. Click "New" and add the location of the MinGW installation. 
  7. cwh blog image

By default, the MinGW installer installs all the files to the "C:\MinGW\bin" folder. If you have changed the installation directory while installing it, you need to give the location of that folder. This is how it will look:

cwh blog image

Click ok to close all the dialogue boxes.


Step 4: Test gcc and g++ compiler:

To test if the gcc compiler or the g++ compiler is installed correctly, open a cmd/PowerShell/terminal window and type the following command.

For gcc compiler:

gcc –v

Copy

 For g++ compiler: 

g++ -v

Copy

cwh blog image


Conclusion: Resolving the "The term gcc is not recognized as the name of..." issue follows a simple procedure once you're familiar with the necessary steps. By verifying the proper installation and configuration of MinGW, you'll ensure a seamless coding experience. Hope that helps and happy coding 🙂

More Posts