0

I have recently installed MinGW for Windows, and I am wanting to compile a program named "object.cpp" at C:\Users\User\. So I open the command prompt, go to my desired directory, and type in the command c++ object.cpp. I am expecting it to return with nothing, but then I receive the error message:

'c++' not recognised as an internal or external command, operable program or batch file

I have tried Setting the Environmental Variable Path to C:\MinGW\bin; but it still comes up with the error message. What should I do to correct this?

Edit:

People have said I should use g++ It still doesn't work.

Also, in C:\MinGW\bin, there exists a c++ and g++ .exe files. So, I do not know what is wrong.

The command prompt is displaying:

C:\Users\User>c++ 'c++' is not recognized as an internal or external command, operable program or batch file. C:\Users\User>g++ 'g++' is not recognized as an internal or external command, operable program or batch file. C:\Users\User>mingw 'mingw' is not recognized as an internal or external command, operable program or batch file.

  • Please edit your question and add the output from running path in a cmd shell. – DavidPostill Nov 5 '17 at 21:16
  • Stop running things in the Windows command prompt and launch MinGW first. If that fails provide the full path to MinGW. You have skipped an installation step. – Ramhound Nov 5 '17 at 22:56
  • @Ramhound You mean the installer? – VortexYT Nov 5 '17 at 22:58
  • No; There is a MinGW executable in the installation directory. Provide the full path to the executables and the .cpp file in your above attempts – Ramhound Nov 5 '17 at 23:02
  • @Ramhound, all I see are a few folders in C:\MinGW – VortexYT Nov 5 '17 at 23:09
2

The C++ compiler that comes with GCC/MinGW uses the command "g++".

  • Nope, please read edit – VortexYT Nov 5 '17 at 21:02
2

c++ not recognised as an internal or external command, operable program or batch file

That is because the name of the c++ compiler is g++.

For those who are just starting out, this will explain how to use MinGW to compile an executable, from C or C++ source, in a command prompt environment.

First you must make sure you have installed MinGW and set the PATH environment variable include the location of MinGW; this is explained Here.

Now, assuming your directory for MinGW is the default "C:\MinGW", and your PATH environment variable is set to include "C:\MinGW\bin", it is easy to start compiling an executable:

Open a command prompt window, and set the current directory to wherever your *.c or *.cpp file is.

Example:

For the file helloworld.cpp in the folder C:\sources\hello enter the commands

cd c:\sources\hello

Now type the compile command

g++ helloworld.cpp -o helloworld.exe

The -o switch specifies the name of the output file, without it the output file would be given a default name of "a.exe".

Source MinGW for First Time Users HOWTO

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.