Share via

C++ Compiler not working

Prabhjoat Riyat 0 Reputation points
2026-05-04T16:49:29.7666667+00:00

I added MinGW-w64 compiler to my VS Code following the instructions on Microsoft VS Code C++ setup documentation but as I try and run a program it doesn't work. I get the following message.

PS C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course> g++ test.cpp -o test.exe

PS C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course> test.exe

test.exe : The term 'test.exe' 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

  • test.exe
  • 
        + CategoryInfo          : ObjectNotFound: (test.exe:String) [], CommandNotFoundException
    
        + FullyQualifiedErrorId : CommandNotFoundException
    
     
    
Developer technologies | Visual Studio | Debugging

3 answers

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 4,945 Reputation points Microsoft External Staff
    2026-05-05T08:06:31.6133333+00:00

    Thank you for reaching out.

    From the information shared, it looks like the issue might be that the executable file is not getting created or not being recognized by the system. To better understand what is happening, please check if test.exe is present in your folder after running the g++ command. Also, kindly share the output of the dir command and let me know if you see any errors during compilation. This will help me assist you further.

    0 comments No comments

  2. Prabhjoat Riyat 0 Reputation points
    2026-05-04T16:56:09.9266667+00:00

    PS C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course> ./test.exe

    ./test.exe : The term './test.exe' 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

    • ./test.exe
    • 
          + CategoryInfo          : ObjectNotFound: (./test.exe:String) [], CommandNotFoundException
      
          + FullyQualifiedErrorId : CommandNotFoundException
      

  3. Q&A Assist
    2026-05-04T16:49:41.3633333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    In PowerShell, the current directory (.) is not on the PATH by default, so running test.exe without a path fails even though the file exists.

    Use one of these options from the same folder where test.exe was built:

    1. Prefix with ./ (recommended in PowerShell):
         PS C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course> g++ test.cpp -o test.exe
         PS C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course> ./test.exe
      
    2. Or specify the full path:
         & "C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course\test.exe"
      

    If the compiler command succeeds but test.exe is not created, list the directory contents to confirm:

    PS ...> dir
    

    If test.exe is missing, fix any compile errors first, then run it as above.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.