Share via

Error with compiler

Prabhjoat Riyat 0 Reputation points
2026-05-04T17:12:47.3233333+00:00

PS C:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course> cd "c:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course" ; if ($?) { g++ hello_world.cpp -o hello_world } ; if ($?) { .\hello_world }

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

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

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

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

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

  • ./hello_world.exe
  • 
        + CategoryInfo          : ObjectNotFound: (./hello_world.exe:String) [], CommandNotFoundException
    
        + FullyQualifiedErrorId : CommandNotFoundException
    
Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.


2 answers

Sort by: Most helpful
  1. Taki Ly (WICLOUD CORPORATION) 1,500 Reputation points Microsoft External Staff Moderator
    2026-05-05T03:57:28.3533333+00:00

    Hello @Prabhjoat Riyat ,

    The CommandNotFoundException errors you are seeing happen because the hello_world.exe file does not exist in your folder. The initial g++ compilation step failed silently in your first command, so the executable was never created.

    Also, as a side note for PowerShell: you cannot run an executable just by typing its name (like hello_world.exe). You must prefix it with .\ or ./ (like you did in your last attempt). But again, it failed because the file wasn't there.

    So, I suggest 2 approaches that you can fix this:

    1. Fix your g++ command-line setup

    1. Check your compiler: Open PowerShell and type g++ --version. If it returns an error (red text), it means g++ is either not installed or not added to your Windows Environment Variables (PATH). You will need to install MinGW/MSYS2 and configure the PATH.
    2. Compile manually: Once g++ is properly installed, run the compile command alone so you can see if there are any code errors: g++ hello_world.cpp -o hello_world.exe
    3. Run the program: If step 2 produces no errors, the .exe file is successfully created. You can now run it: .\hello_world.exe

    2. Use Visual Studio

    As Viorel pointed out, since you are taking the "Microsoft C++ Course", the curriculum is likely designed around Visual Studio, not g++.

    Instead of manually configuring compilers and typing commands, I recommend downloading Visual Studio Community. Install the "Desktop development with C++" workload, open your .cpp file there, and simply press Ctrl + F5 (or the green Run button). It will automatically compile and run the program for you without these PowerShell path issues.

    I hope this helps with your question. If you found this informative, please consider providing feedback following this guide.

    Thank you.

    Was this answer helpful?


  2. Q&A Assist
    2026-05-04T17:12:59.49+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    hello_world.exe is not being found because the compiler command did not actually produce the executable in the current environment.

    From the transcript, the command used is:

    cd "c:\Users\Prabh\OneDrive\Documents\Prabhjoat University\programming\Microsoft C++ Course" ; if ($?) { g++ hello_world.cpp -o hello_world } ; if ($?) { .\hello_world }
    

    Key points based on the provided guidance for compiling from the command line:

    1. Use the correct developer command prompt
      • For MSVC, a developer command prompt must be used so that the compiler and tools are on the PATH. The documentation shows using cl from a Developer Command Prompt for VS rather than invoking a compiler from a regular PowerShell window.
      • Open Developer Command Prompt for VS from the Start menu (Visual Studio folder), then verify the compiler works by running:
             cl
        
        and confirming output similar to:
             Microsoft (R) C/C++ Optimizing Compiler Version ...
             usage: cl [ option... ] filename... [ /link linkoption... ]
        
    2. Create and compile the program in that prompt
      • In the developer command prompt:
             md C:\hello
             cd C:\hello
             notepad hello.cpp
        
      • Enter the sample code and save it, as shown in the documentation:
             #include <iostream>
             using namespace std;
             int main()
             {
                 cout << "Hello, world, from Microsoft C++!" << endl;
             }
        
      • Compile it with MSVC:
             cl hello.cpp
        
      • This produces hello.exe in the same directory.
    3. Run the program from the same directory
      • Still in the developer command prompt, in the directory where the .exe was created, run:
             hello
        
      • The program should display the expected text and exit.

    If an error such as 'cl' is not recognized as an internal or external command, operable program or batch file appears when running cl, the environment is not set up correctly and the MSVC installation or the use of the proper developer command prompt must be fixed before continuing.


    References:

    Was this answer helpful?

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.