O compilador C ++ que vem com o GCC / MinGW usa o comando "g ++".
Instalei recentemente o MinGW para Windows e estou querendo compilar um programa chamado "object.cpp" at C:\Users\User\ . Então eu abro o prompt de comando, vou para o meu diretório desejado e digite o comando c++ object.cpp . Estou esperando que ele retorne sem nada, mas então recebo a mensagem de erro:
'c++' not recognised as an internal or external command, operable program or batch file
Eu tentei Definir a variável ambiental Path para C:\MinGW\bin; , mas ainda aparece a mensagem de erro. O que devo fazer para corrigir isso?
Editar:
As pessoas disseram que eu deveria usar g++ Ainda não funciona.
Além disso, em C:\MinGW\bin , existem arquivos c++ e g++ .exe . Então, eu não sei o que está errado.
O prompt de comando está sendo exibido:
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.
c++ não reconhecido como um comando interno ou externo, programa operável ou arquivo em lote Isso porque o nome do compilador c ++ é 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\helloNow type the compile command
g++ helloworld.cpp -o helloworld.exeThe -o switch specifies the name of the output file, without it the output file would be given a default name of "a.exe".